| 
 Posted by David Precious on 11/29/05 16:16 
On 29/11/05, Sichta Daniel <Daniel.Sichta@siemens.com> wrote: 
> Hi all !!! 
> 
> I have string like this "1234567890" 
> 
> I need to split this into array like this 
> a[0] = "12" 
> a[1] = "34" 
> a[2] = "56" 
> a[3] = "78" 
> a[4] = "90" 
> 
> I know that for this is preg_split, but I don't know the string patern 
> for split. 
> Thank you in advance !! 
 
 
No, preg_split would be overkill here, you want to take a look at str_split: 
 
http://uk.php.net/manual/en/function.str-split.php 
 
To achieve what you described above: 
 
<?php 
$str = '1234567890'; 
$a = str_split($str, 2); 
?> 
 
Simple eh?  Does exactly what it says on the tin. 
 
:-) 
 
Cheers 
 
David Precious 
http://www.preshweb.co.uk/
 
[Back to original message] 
 |