didgydont Posted September 6, 2008 Share Posted September 6, 2008 hi all not real sure about how to describe this one basicly i have a serial number that can be 6 to 15 characters and i need to make each section a value eg 5j39n2 needs to make $v1 = 5; $v2 = j; $v3 = 3; $v4 = 9; $v5 = n; $v6 = 2; but one with 15 characters needs to go to $v1 to $v15 any ideas Link to comment https://forums.phpfreaks.com/topic/122984-solved-extarct-and-assign-value/ Share on other sites More sharing options...
GingerRobot Posted September 6, 2008 Share Posted September 6, 2008 Store the characters in an array rather than a separate variable. Otherwise you have to keep track of how many variables you've created and it gets clumsy. $str = '5j39n2'; $c = array(); for($x=0;$x<strlen($str);$x++){ $c[] = $str[$x]; } echo '<pre>'.print_r($c,1).'</pre>'; Edit: Or, if you're using PHP 5, there's a function to do it for you: $str = '5j39n2'; $c = str_split($str); echo '<pre>'.print_r($c,1).'</pre>'; Link to comment https://forums.phpfreaks.com/topic/122984-solved-extarct-and-assign-value/#findComment-635094 Share on other sites More sharing options...
didgydont Posted September 6, 2008 Author Share Posted September 6, 2008 thank you so much i went with your first sugestion Link to comment https://forums.phpfreaks.com/topic/122984-solved-extarct-and-assign-value/#findComment-635105 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.