blackwater dev wrote:
How can I take a string and create an array?
Example,
A12B05C45D34
I need to split this into chunks of three A12,B05,C45..etc?
Thanks!
|
use str_split()
if you dont have php5, you can use the following code:
|
<?php
if (!function_exists('str_split')) {
function str_split ($str, $size = 1) {
$arr = array();
for ($i = 0 ; $i < strlen($str) ; $i += $size) {
$arr[] = substr($str,$i,$size);
}
return $arr;
}
}
$array = str_split('A12B05C45D34',3)
print_r($array);
?>
||
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php