I have a lot of URL's in a database, that are like this
http://www.domain.com/something/?name=o ... d2=1231515
How would I extract the url value from this as a text string?
Thanks!
extract parameter from a url
Moderator: General Moderators
- aceconcepts
- DevNet Resident
- Posts: 1424
- Joined: Mon Feb 06, 2006 11:26 am
- Location: London
Re: extract parameter from a url
What do you mean by url value?
- John Cartwright
- Site Admin
- Posts: 11470
- Joined: Tue Dec 23, 2003 2:10 am
- Location: Toronto
- Contact:
Re: extract parameter from a url
Take a look at parse_url() and parse_str() for the query string
Re: extract parameter from a url
Code: Select all
<?php
$url = "http://www.domain.com/something/?name=name&d2=1231515";
$parse_result = parse_url($url);
if (!empty($parse_result['query'])){
$values = array();
parse_str($parse_result['query'], $values);
print_r($values);
}
?>