PHP Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsProgramming LanguagesPHP Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old January 30th, 2000, 03:35 PM
Dass Dass is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 1999
Posts: 5 Dass User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Hi.


Can someone help me with a regexp that I need?
$html="<b><a href="url">somthing</a><br><a href="url">somthing here</a>";

What I need to do is collect all the html links inside a string (<a href="url">somthing</a> ) and add them to an array.

If anyone can help me, that would be very appretiated.

Thanks.

[This message has been edited by Dass (edited January 30, 2000).]

Reply With Quote
  #2  
Old January 31st, 2000, 10:12 AM
Kyuzo Kyuzo is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 1999
Location: Annapolis, Maryland US
Posts: 113 Kyuzo User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 14
This is kind of a kludge, but it should point you in the right direction

<?

$html="<HTML><BODY><P><A HREF="url1">first link</A><P><A HREF="url2">second
link</A></BODY></HTML>";

$firstlist=split("<[/]?a|A[>]?", $html);

// find out which indexes contain "HREF" or "href"
// if it does, prepend "<A " and append "</A>" to it and put in new array

for($i=0; $i<count($firstlist); $i++)
{
if(eregi("HREF", $firstlist[$i]))
$secondlist[]="<A ".$firstlist[$i]."</A>";
}


// $secondlist array should contain all the links

for($i=0; $i<count($secondlist); $i++)
print"$secondlist[$i]<br>";


?>

Reply With Quote
  #3  
Old February 3rd, 2000, 01:10 PM
Dass Dass is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 1999
Posts: 5 Dass User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
I played around and got did the following:

if( eregi('<a href="<[^>]*>">"<[^>]*></a>', $input, $links));
{
$customlinks .= "<a href="$links[1]">$links[2]</a><br>";
}

But It is giving me errors:
Warning: No such index in string in /home/rob/www/customlinks.php3 on line 67

Warning: No such index in string in /home/rob/www/customlinks.php3 on line 67

Which I guess means that $links[1] and [2] don't exist?

Is there somthing wrong with my code?
Thanks.

Reply With Quote
  #4  
Old February 3rd, 2000, 04:13 PM
Kyuzo Kyuzo is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 1999
Location: Annapolis, Maryland US
Posts: 113 Kyuzo User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 14
I'm having difficulty understanding the pattern in your eregi() function. Anyhow, I believe you have to escape any quotes -> " in the pattern string to match a literal quote -> " in the target string

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesPHP Development > regexp help please?

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap