This is a discussion on PHP variable splitting within the alt.comp.lang.php forums, part of the PHP Programming Forums category; Is there a command in PHP that will allow me to split a text variable into an array by length ...
|
|||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
Is there a command in PHP that will allow me to split a text variable into
an array by length rather than using a delimiter? What I want to do is have it separate into an array entity for every 2 characters. So if you put in the word "european" you would get: $array[0] = "eu" $array[1] = "ro" $array[2] = "pe" $array[3] = "an" Is there a PHP command that will do this for me in one step? |
|
|||
|
On Fri, 27 Aug 2004 16:53:23 -0400, "Papago" <me@myplace.com> wrote:
>Is there a command in PHP that will allow me to split a text variable into >an array by length rather than using a delimiter? What I want to do is have >it separate into an array entity for every 2 characters. So if you put in >the word "european" you would get: > >$array[0] = "eu" >$array[1] = "ro" >$array[2] = "pe" >$array[3] = "an" > >Is there a PHP command that will do this for me in one step? http://uk.php.net/manual/en/function.str-split.php Otherwise a simple loop with substr would do it. Or preg_split. -- Andy Hassall / <andy@andyh.co.uk> / <http://www.andyh.co.uk> <http://www.andyhsoftware.co.uk/space> Space: disk usage analysis tool |