Jump to content

help with preg_replace ?


slashpine

Recommended Posts

I am guessing this "preg_replace" is the best option in this?

using the code below ( see post)
http://www.phpfreaks.com/forums/index.php/topic,106136.0.html
many of the addresses (addr1) have a # followed by either a letter or a number i.e., # A , # 400  etc. etc.
Can I use preg_replace?  so the scritp ignores the # and everything following it in that column ?

[code]    $url = "http://us.rd.yahoo.com/maps/us/insert/Tmap/extmap/*-http://maps.yahoo.com/maps_result?addr=";
    $url.= str_replace(" ","+",$query_data['addr1']);
    $url.= "&csz=";
    $url1 = str_replace(",","%2C",$query_data['addr2']);
    $url.= str_replace(" ","+",$url1). "&country=us";
    echo "<a href='". $url. "'><img src='images/maplink.gif' width='89' height='17' alt=''/></a>";[/code]
Link to comment
https://forums.phpfreaks.com/topic/21201-help-with-preg_replace/
Share on other sites

[code]$url = "http://us.rd.yahoo.com/maps/us/insert/Tmap/extmap/*-http://maps.yahoo.com/maps_result?addr=";
    $url = "http://us.rd.yahoo.com/maps/us/insert/Tmap/extmap/*-http://maps.yahoo.com/maps_result?addr=";
    $url.= str_replace(" ","+",$row['address']);
    $url.= "&amp;csz=";
    $url1 = str_replace(",","%2C",$row['city']);
    $url.= str_replace(" ","+",$url1). ",GA+&amp;country=us";[/code]

this is edited from the  code in the original in thread I cited for my column names/query

This works great as long as there is no # A or # 800  etc after the street address ($address)
Link to comment
https://forums.phpfreaks.com/topic/21201-help-with-preg_replace/#findComment-94277
Share on other sites

thanks for the reply but I don't see how to apply that to the code cited...the script parses the "address" from the database and builds a URL that displays  a map from Yahoo

can you expand on how I can emply this or possibly suggest another way of  eliminating the problem of the # and what follows...?

Thanks again...

[edited]

I solved this problem by changing the "#" character in the table column to the word "Unit" this allows the the script tpo parse the correct address into the URL (script)

Thanks again for all the help...
Link to comment
https://forums.phpfreaks.com/topic/21201-help-with-preg_replace/#findComment-94333
Share on other sites

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.