Okay, here is what I have going on.
Some background: I'm making changes to an existing WordPress website that someone else built. They created a textarea where the client copies and pastes an iframe embed for a Google Map. This is for properties that the client posts on their website.
The dilemma: This is all well and good but I'm rebuilding the detail page for their properties and I want to strip out all of the iframe information and only leave the property address so that I can use it to create a new map via a Google Maps V3 jQuery plugin.
I want to turn this:
<iframe width="425" height="350" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="http://maps.google.com/maps?f=q&source=s_q&hl=en&geocode=&q=5475+NW+75+AVE,+Ocala+FL+34482&aq=&sll=29.300577,-82.294762&sspn=0.006755,0.013304&vpsrc=0&ie=UTF8&hq=&hnear=5475+NW+75th+Ave,+Ocala,+Florida+34482&t=m&z=14&ll=29.244022,-82.241361&output=embed"></iframe><br /><small><a href="http://maps.google.com/maps?f=q&source=embed&hl=en&geocode=&q=5475+NW+75+AVE,+Ocala+FL+34482&aq=&sll=29.300577,-82.294762&sspn=0.006755,0.013304&vpsrc=0&ie=UTF8&hq=&hnear=5475+NW+75th+Ave,+Ocala,+Florida+34482&t=m&z=14&ll=29.244022,-82.241361" style="color:#0000FF;text-align:left">View Larger Map</a></small>
Into this:
5475 NW 75 AVE, Ocala FL 34482
I think I'm on the right track by looking into preg_replace() but the regular expression for this is what gets me. Alternatively, if I can extract the coordinates that would help too. I can use either the address or the lat and long coordinates to get the job done.
Thanks in advance for any assistance I can get!
Edit with solution since my SO rep is still low:
Thanks to Mario I was able to get the job done. Here is my finalized code for anyone that it may help.
You started with this:
<iframe width="425" height="350" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="http://maps.google.com/maps?f=q&source=s_q&hl=en&geocode=&q=5475+NW+75+AVE,+Ocala+FL+34482&aq=&sll=29.300577,-82.294762&sspn=0.006755,0.013304&vpsrc=0&ie=UTF8&hq=&hnear=5475+NW+75th+Ave,+Ocala,+Florida+34482&t=m&z=14&ll=29.244022,-82.241361&output=embed"></iframe><br /><small><a href="http://maps.google.com/maps?f=q&source=embed&hl=en&geocode=&q=5475+NW+75+AVE,+Ocala+FL+34482&aq=&sll=29.300577,-82.294762&sspn=0.006755,0.013304&vpsrc=0&ie=UTF8&hq=&hnear=5475+NW+75th+Ave,+Ocala,+Florida+34482&t=m&z=14&ll=29.244022,-82.241361" style="color:#0000FF;text-align:left">View Larger Map</a></small>
And you want this:
5475 NW 75 AVE, Ocala FL 34482
This is what worked for me:
// We first find and extract the 'src' from the iframe
// $map is my original iframe embed
// $q is our extracted and stripped text
preg_match('#q=([^&"]+)#', $map, $match)
and ($q = urldecode($match[1]));
// Now you can echo out the address or use it elsewhere.
// In my case, I am using jQuery goMap (http://www.pittss.lv/jquery/gomap)
// and can add a new point on the map via $q
echo $q;