How can I split a 6 digit number in to 2 separate numbers?

A

Anonymous

Guest
Hello
I have a 6 digit number and I want to split it to 2 separate numbers do you know how can I do this ?
For example the number 200509 I want to split it in to 2005 and 09.

Thank you.
 
spyros said:
Hello
I have a 6 digit number and I want to split it to 2 separate numbers do you know how can I do this ?
For example the number 200509 I want to split it in to 2005 and 09.

Thank you.
http://ua2.php.net/manual/en/function.preg-split.php
see example.
 
If it's always a constant pattern you could do it without using preg.

i.e. if its a date with out spaces 20080514 (14/05/2008)
Code:
<?php

$datestring = "20080514";

$year = substr( $datestring, 0, 4 );
$month = substr( $datestring, 4, 2 );
$day = substr( $datestring, 6, 2 );

?>
 
Back
Top