Jump to content

HELP: how to skip a word with \*word*\ when extracting?


Recommended Posts

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

???

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.

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.