|
Posted by Rik on 08/16/06 21:12
Don't toppost
wegenern@gmail.com wrote:
> Chung Leong wrote:
>> friglob wrote:
>>> Just found out...
>>>
>>> preg_split("%-%",$string_to_search,-1,PREG_SPLIT_NO_EMPTY);
>>>
>>> Thank you for your time.
>>
>> preg_split("/-+/", $string_to_search) is a somewhat more orthodox
>> solution.
> $string = "-1--3--8--22--550--1028-";
>
> if(ereg
>
("-([0-9]{1})--([0-9]{1})--([0-9]{1})--([0-9]{2})--([0-9]{3})--([0-9]{4})-",
> $string, $regs)){
> $array_set = array_splice($regs,1);
> print_r($regs);
> print_r($array_set); // <- This is the output requested.
> }
But a lot more undynamic & slower, I'd suggest using Chung's solution. It's
the fastest and the easiest altered.
Grtz,
--
Rik Wasmus
[Back to original message]
|