GHolmes
0
Q:

php split

// Example 1
$pizza  = "piece1 piece2 piece3 piece4 piece5 piece6";
$pieces = explode(" ", $pizza);
echo $pieces[0]; // piece1
echo $pieces[1]; // piece2
6
<?php
// It doesnt get any better than this Example
$pizza  = "piece1 piece2 piece3 piece4 piece5 piece6";
$pieces = explode(" ", $pizza);
echo $pieces[0]; // piece1
echo $pieces[1]; // piece2
10
$colors  = "red,blue,green,orange";
$colorsArray = explode(",", $colors);
20

<?php

$str = "Hello world. It's a beautiful day.";

print_r (explode(" ",$str));

?> 
0

 <?php
$str = 'one,two,three,four';
// to get all of the numbers: [one, two, three, four]
$numbers1 = explode(',',$str)
// same as $str
$numbers2 = explode(',',$str,0);
 
// breakes the string into two parts
$numbers3 = explode(',',$str,2);

// the last result will be removed
$numbers4 = explode(',',$str,-1);
?> 
 
6
explode(" ","Geeks for Geeks")
4

<?php
// Beispiel 1
$pizza  = "Teil1 Teil2 Teil3 Teil4 Teil5 Teil6";
$teile = explode(" ", $pizza);
echo $teile[0]; // Teil1
echo $teile[1]; // Teil2

// Beispiel 2
$data = "foo:*:1023:1000::/home/foo:/bin/sh";
list($user, $pass, $uid, $gid, $gecos, $home, $shell) = explode(":", $data);
echo $user; // foo
echo $pass; // *

?>

0
$nums = ""; //Declare a variable with empty set.

$nums .= $number; //concatenate the empty string with the integer $number You can also use

$nums = $nums.$number; // this and the expression above do the same thing choose whichever you
                     //like.. This concatenation automatically converts integer to string
$nums[0] is now 4, $nums[1] is now 5, etc..
$length = strlen($nums); // This is the length of your integer.
$target = strlen($nums) -1; // target the last digit in the string;    
$last_digit = $nums[$target]; // This is the value of 5. Last digit in the (now string)
2
explode()
0

New to Communities?

Join the community