Hi Guys and Girls, I'm currently trying to make a script that just decodes strings to get two values, so I need to find where they start and where they end, preferably I'd like to create an array with them so for example number 1 would be $num[0] and number 2 $num[1]. The strings all vary, so I can't explode them, information like: 05place11time 03location6seconds 8ct5tm Although, there tends to be information before and after those, and ideas or functions I can use to get them out? I thought I could find the first position for a number, the last position, then remove all the characters though some how break them apart? Any other ideas? Or solutions? Thanks
I don't quiet understand what you need. However, I know strings can be broken using substr. This function will return an array of the string: function makearray($string){ $array_let = array(); $x=0; $len = strlen($string); while($x <= $len){ array_push($array_let,substr($string,$x,1)); $x++; } return $array_let; } PHP:
I don't quiet understand what you need. However, I know strings can be broken using substr. This function will return an array of the string: function makearray($string){ $array_let = array(); $x=0; $len = strlen($string); while($x <= $len){ array_push($array_let,substr($string,$x,1)); $x++; } return $array_let; } PHP:
preg_match("/([a-zA-Z]*)([0-9]*)([a-zA-Z]*)([0-9]*)/", $string, $matches); $matches will return an array containing: element 1 = the first text part element 2 = the first numeric part element 3 = the second text part element 4 = the second numeric part