View Full Version : How can I split a 6 digit number in to 2 separate numbers?

07-22-2007, 11:01 AM
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.

07-22-2007, 12:17 PM
like this:

list($year,$month) = str_split(200709,4);

Basically, you're wanting to treat the number as a string (which PHP will do for you) and split it after the 4th character, giving a 4-character 'chunk' and a 2-character one. str_split returns an array, so using list() lets you assign the values directly to variables.