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
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
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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.