Solved

URL value extraction

Posted on 2007-04-02
5
154 Views
Last Modified: 2007-04-02
ive got a string like this:

$string = 'Clearly describe your <a href="">question</a> or problem, along with <a href="">specific information</a> such as <a href="">product names</a>, OS, and any error messages.';

how can i extract all the values between <a></a> from the above string?  for example the values from the above string should be: question, specific information & product names.
0
Comment
Question by:ellandrd
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 
LVL 48

Accepted Solution

by:
hernst42 earned 500 total points
ID: 18834929
use preg_match_all for this like:
preg_match_all('/<a[^>]+>(.*?)<\/a>/', $string, $m);
$m[1] will be an array with the requested information
0
 
LVL 16

Author Comment

by:ellandrd
ID: 18834958
yes but my string can have more than 1 href.
0
 
LVL 48

Expert Comment

by:hernst42
ID: 18834979
yes and the example extracts them all, Haven't you tried it or do you get results which sould not be in the result?
0
 
LVL 16

Author Comment

by:ellandrd
ID: 18835044
my results are:

Array ( [0] => Array ( [0] => Google  ) [1] => Array ( [0] => Google ) )

so in order to print out info i have to use: print_r();
0
 
LVL 16

Author Comment

by:ellandrd
ID: 18835053
got it to display how i want it... thank you
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Log in through ID 5 36
migrating to phpbb forum from vBulletin 4.2 3 26
PHP: Filling Out/Creating a PDF 29 94
Convert php array to comma seperated list 19 33
Part of the Global Positioning System A geocode (https://developers.google.com/maps/documentation/geocoding/) is the major subset of a GPS coordinate (http://en.wikipedia.org/wiki/Global_Positioning_System), the other parts being the altitude and t…
This article discusses how to create an extensible mechanism for linked drop downs.
The viewer will learn how to count occurrences of each item in an array.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

740 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question