Jump to content

Splitting up 4 numbers


master82

Recommended Posts

...or, you could just treat the string as an array:
[code]
<?php
$string = "Test String";
for ($i = 0; $i < strlen($string); $i++) echo "{$string[$i]}<br />\n";
?>
[/code]

so, for your example, i'd do something like this:
[code]
<?php
$string = "9172";
for ($i = 1; $i <= strlen($string); $i++) {
eval("\$var$i = \$string[\$i - 1];");
}
?>
[/code]

good luck
Link to comment
https://forums.phpfreaks.com/topic/19157-splitting-up-4-numbers/#findComment-82890
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.