homer.favenir Posted May 5, 2008 Share Posted May 5, 2008 hi all, i have a script that extracts address, city, phone but it also extracts \TOLL FREE DIAL '1' & THEN\ and \*WWW.*ARMORATL.*COM\ or any word with \*WORD*\. to give you an idea here is my script: foreach ($a as $row => $line) { //$data[0] = trim(substr($line, 0, 16))."<br />"; //$data[1] = trim(substr($line, 16,125))."<br />"; $data[2] = trim(substr($line,141, 55))."<br />"; $data[3] = trim(substr($line,196, 32))."<br />"; $data[4] = trim(substr($line,228, 14))."<br />"; //$data[5] = trim(substr($line,240, 2))."<br />"; if ($data[2]!= "<br />" or $data[3] != "<br />" or $data[4] != "<br />") $final[] = $data; } it works really fine, but it extracts also those words with \*word*\ $data[2] is the address, $data[3] is the city and $data[4] is the phone. but sometimes the \*word*\ is in the address which is supposed to be not included. anyone pleaseeee.... thanks ??? Link to comment https://forums.phpfreaks.com/topic/104257-help-how-to-skip-a-word-with-word-when-extracting/ Share on other sites More sharing options...
Spaceman-Spiff Posted May 5, 2008 Share Posted May 5, 2008 You can do some validation using strstr() function, for example: $data[2] = trim(substr($line,141, 55))."<br />"; if (strstr($data[2], "\*word*\") $data[2] = ''; Alternately, you can use the strpos() function, or preg_match() function for something more complex. Link to comment https://forums.phpfreaks.com/topic/104257-help-how-to-skip-a-word-with-word-when-extracting/#findComment-533829 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.