Hi All,
I want to split a string like "67* 90+ 86 -23" into tokens as '67' '*' '90' '+' '86' '-' '23'
Plss help me do it...
Moderators: macek, egami, gesf

<?php
$a = "67* 90+ 86 -23";
$b = str_split($a, 2);
echo '<pre>';
print_r($a);
echo '</pre>';
/* Result:
Array
(
[0] => 67
[1] => *
[2] => 90
[3] => +
[4] => 86
[5] => -
[6] => 23
)
*/
$c = '';
foreach($b as $key => $value) {
$v = trim($value);
$c .= " '$v' ";
}
echo $c;
// Result: '67' '*' '90' '+' '86' '-' '23'

Return to PHP coding => General
Users browsing this forum: Google [Bot] and 3 guests