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.
Look at [man]substr[/man]. And look here to get other string functions.
Example
<?php $num = 342647; $part1 = substr($num, 0, 3); // 342 $part2 = substr($num, -3, 3); // 647 echo $part1; echo "<br>"; echo $part2; ?>
Hold on, this is the ClientSide Technologies forum.
I don't know but this thought might be irrelavent, but I'll ask as it may present another solution.
That number looks like a date and I was just wondering how that number was being generated. I guess it could just be part of a file already or part of some database. But outside of that I think there might be a better way split it.
If we're talking JavaScript, it's similar:
// assume date_string is a string of digits: year = date_string.substring(1,4); month = date_string.substring(5,6);