Re: Best way to split a string of numbers into segments.
| From: | Mike | Date: | Tue, 02 Dec 2003 15:37:59 +0000 |
| Subject: | Re: Best way to split a string of numbers into segments. | ||
| References: | 1 2 3 4 5 6 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-171593@lists.php.net to get a copy of this message | ||
>From the manual preg_split
Returns an array containing substrings of subject split along boundaries
matched by pattern.
since you dont have any borders, this is unlikely to help you....
the only was i can see to do it is a quite long way
$mydate = "20031202";
$date = array();
preg_match("/(\d{4})(\d{2})(\d{2})/", $mydate, $date);
list($x, $y, $d, $m) = $date;
echo $d." / ".$m." / ".$y ."\n";
Mike
On Tue, 2003-12-02 at 15:15, Tom wrote:
> I have noted the "'s.
> Could you send me a complete piece of code, please?
> I cannot for the life of me get it to work, at all.
>
> Mike wrote:
>
> >list ($a, $b, $c) = preg_split ("/(\d{4})(\d{2})(\d{2})/");
> >
> >note the "'s
> >
> >
> >
> >>list ($a, $b, $c) = preg_split (/(\d{4})(\d{2})(\d{2})/);
> >> > parse error, unexpected '/', expecting ')'
> >>
> >>
> >
> >
> >
>