I have a string which I want to split up in an array.
Example: "My name is Peter"
Should result in:
$array[0] = "My" $array[1] = " n" $array[2] = "am" $array[3] = "e " $array[4] = "is" $array[5] = " P" $array[6] = "et" $array[7] = "er"
How about looping through using for($i=0; $i<strlen($string); $i+=2)
and then using the substr funciton to take 2 characters starting at $i, and putting them into $array[] (this appends to the end of the array so no number is needed).
Hope that helps,
Danny
Will try that. Thanks!
Good luck!
Check <b>explode()</b> function - it splits string into an array of elements, or implode() it takes array elements and puts them as one string.
Di
You could try using regular expressions. eg.
ereg( "(.{2})", $String, $Matches );
$Matches should be an array of 2 character strings.
Im not sure if this would work. Give it a try.