homer.favenir Posted May 15, 2008 Share Posted May 15, 2008 hi to all i need help for my script please. the case is like this 2HS REFUGE PREGNANCY & RESOURCE CENTER REFUGE PREGNANCY RESOURCE CENTER 1307 MILSTEAD AV N*E CNYRS 30012770 922-5939V2 1HS SOURCE PREGNANCY CARE CENTER 10258 FLAT SHOALS RD COVINGTON 30014770 786-1531V2 what i like to do is from the column of strt # which is column 142, the script will search for an integer and will stop if it sees a white space and will store that integer to a variable, and what follows the white space is the strt name, and it will store it in a variable also, after the strt name the searching will stop if it sees a tab. objective is to separate the strt # and strt name from address column. the addresses are: 1307 MILSTEAD AV N*E 10258 FLAT SHOALS RD anyone please thanks Link to comment https://forums.phpfreaks.com/topic/105683-search-integer-stop-at-white-space-and-store-in-variable/ Share on other sites More sharing options...
blackcell Posted May 15, 2008 Share Posted May 15, 2008 You can try to use a loop to progress the string and check to see if the digit is numerical. If it is store it to a string $addressNumber and if not store it to $addressStreet Link to comment https://forums.phpfreaks.com/topic/105683-search-integer-stop-at-white-space-and-store-in-variable/#findComment-541493 Share on other sites More sharing options...
homer.favenir Posted May 15, 2008 Author Share Posted May 15, 2008 my problem is the strt # is read by php as a string,i convert it to integer, but the problem is how can php know that it is an integer for him to convert it to integer Link to comment https://forums.phpfreaks.com/topic/105683-search-integer-stop-at-white-space-and-store-in-variable/#findComment-541496 Share on other sites More sharing options...
redarrow Posted May 15, 2008 Share Posted May 15, 2008 I worked on somethink like that this way mate......... $res1 anythink with numbers... $res2 anythink with charecters <?php $a=array("12343323","asdfjferje","444443432434","53453453455"); foreach($a as $contents){ if(preg_match("/[0-9]/",$contents)){ $contents1[]=$contents; }else{ $contents2[]=$contents; } } foreach($contents1 as $res1){ echo " This holds all the numbers in varable \$res1 $res1 <br> "; } foreach($contents2 as $res2){ echo " This holds all the charecters in varable \$res2 $res2 <br> "; } ?> Link to comment https://forums.phpfreaks.com/topic/105683-search-integer-stop-at-white-space-and-store-in-variable/#findComment-541544 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.