1 $str = "Hello, kinjal, how, are, you";
2
3 // it will convert string to array
4 $s1 = explode(",", $str);
5 echo "<pre>";
6 print_r($s1);
1
2<?php
3// Example 1
4$pizza = "piece1 piece2 piece3 piece4 piece5 piece6";
5$pieces = explode(" ", $pizza);
6echo $pieces[0]; // piece1
7echo $pieces[1]; // piece2
8
9// Example 2
10$data = "foo:*:1023:1000::/home/foo:/bin/sh";
11list($user, $pass, $uid, $gid, $gecos, $home, $shell) = explode(":", $data);
12echo $user; // foo
13echo $pass; // *
14
15?>
16
17
1$nums = ""; //Declare a variable with empty set.
2
3$nums .= $number; //concatenate the empty string with the integer $number You can also use
4
5$nums = $nums.$number; // this and the expression above do the same thing choose whichever you
6 //like.. This concatenation automatically converts integer to string
7$nums[0] is now 4, $nums[1] is now 5, etc..
8$length = strlen($nums); // This is the length of your integer.
9$target = strlen($nums) -1; // target the last digit in the string;
10$last_digit = $nums[$target]; // This is the value of 5. Last digit in the (now string)