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 !!
Dan
Hi Dan,
Try:
$a = split(\n, chunk_split('1234567890', 2), 5);
php.net/chunk_split
php.net/split
Cheers,
David Grant
Sichta Daniel 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
On 29/11/05, Sichta Daniel [EMAIL PROTECTED] 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
There is an error in this code. It should in fact read:
$a = split(\r\n, chunk_split('1234567890', 2), 5);
OR
$a = split(\n, chunk_split('1234567890', 2, \n), 5);
David Grant wrote:
Hi Dan,
Try:
$a = split(\n, chunk_split('1234567890', 2), 5);
php.net/chunk_split
php.net/split
No, preg_split would be overkill here, you want to take a look at
str_split:
Sorry I forgott to tell that I'm not using PHP 5.x :-)
Ahhh, right - my answer won't be of much use to you then :-)
In that case, David Grant's suggestion of using chunk_split() in
combination with split() is
5 matches
Mail list logo