Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7909187
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T12:17:57+00:00 2026-06-03T12:17:57+00:00

Okay, here is what I have going on. Some background: I’m making changes to

  • 0

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;
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T12:17:59+00:00Added an answer on June 3, 2026 at 12:17 pm

    If you insist on the overkill solution, you would first use a HTML traversal library like QueryPath to split up the HTML and get the attribute:

    $url = qp($html)->find("iframe")->attr("src");
    

    But that’s pointless and in practice you should just extract the URL from your text snippet:

    preg_match('#http://[^"\']+#', $html, $match)
    and ($url = $match[0]);
    

    From there just split it up with parse_url($url, PHP_URL_QUERY) and extract the bits with parse_str($qs, $vars) so you get $var["q"].

    But if it’s a somewhat coherent input you could just carve out the q= parameter with:

    preg_match('#q=([^&"]+)#', $html, $match)
    and ($q = urldecode($match[1]));
    

    Even more lazy would be just using parse_str on the whole HTML snippet, and praying the leading and trailing garbage does not interfere with the desired snippet.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Okay here is what I'm trying to do: I have a model object that
Okay, here's the scenario. I have a utility that processes tons of records, and
Okay, so here's my problem: I have a list of members on a website,
Okay, I'm stumped here. I have a control that is comprised of a table.
Okay, so here's a problem I'm running into. I have some classes in my
Okay, so we have a utility here in-house that generates business-model classes from our
Okay here's my situation. I have the following branches development development-kirby (270 commits ahead
Okay basically here's where I'm at. I have a list of PropertyDescriptor objects. These
Okay, here's the situation: We have a table of about 50 columns (created by
Okay so I have this mode: class Posts(db.Model): rand1 = db.FloatProperty() #other models here

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.