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 June 10th, 2000, 12:57 AM
tennisguy tennisguy is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2000
Location: Cleveland
Posts: 16 tennisguy User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Hi

I have the following HTML snippet:

$string=<IMG SRC=foo><FONT COLOR=red>foofoofoo</FONT>

I would like to get the HTML tags and place them into an array called $var so that
var[1]=<IMG SRC=foo>;
var[2]=<FONT COLOR=red>;
var[3]=</FONT>;

I tried the following code but with no luck:

eregi("(<.*> )",$string,$var);

Any help would be appreciated!!!

Reply With Quote
  #2  
Old June 10th, 2000, 02:57 AM
Shiju Rajan's Avatar
Shiju Rajan Shiju Rajan is offline
.Net Developer
Dev Shed Novice (500 - 999 posts)
 
Join Date: Feb 2000
Location: London
Posts: 987 Shiju Rajan User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 h 26 m 22 sec
Reputation Power: 14
Send a message via MSN to Shiju Rajan Send a message via Yahoo to Shiju Rajan
You should pass the values to the variable in double quotes.


var[1]=<IMG SRC=foo>;
var[2]=<FONT COLOR=red>;
var[3]=</FONT>;


This was wrong actaully.

$var[]="<IMG SRC=foo>";
$var[]="<FONT COLOR=red>";
$var[]="</FONT>";

if you want to pass these tags to just a variable then you could use the following..

$var="<IMG SRC=foo>";
$var.="<FONT COLOR=red>";
$var.="</FONT>";




------------------
SR -
shiju.dreamcenter.net

"The fear of the LORD is the beginning of knowledge..."

Reply With Quote
  #3  
Old June 10th, 2000, 01:37 PM
tennisguy tennisguy is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2000
Location: Cleveland
Posts: 16 tennisguy User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Thanks for your reply but I am afraid that you have misunderstood my question. I have a line of arbitrary HTML code with x tags. I need a way to use regular expressions to store each of those tags into an array. Can this be done with ereg()?

Thank you!

Reply With Quote
  #4  
Old June 12th, 2000, 08:11 AM
scollo scollo is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 1999
Posts: 114 scollo User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 42 m 44 sec
Reputation Power: 15
I doubt you could do this with a single regular expression. If the page contains JavaScript, for example, there might be many < characters that would throw your regexp off.:

<script language='javascript'>
if (x < 10 && y > 20) { ...


In this case, you would get < 10 && y > as an HTML tag. Similarly, if the content of the page contained any < characters, you'd get thrown.

You might want to write a loop that checks the file one character at a time. When it hits a <script or <SCRIPT, make it skip ahead until it gets a </script or </SCRIPT (unless of course, you also want to capture any HTML tags embedded in the JavaScript. Then you'll have to come up with similar rules to handle <s that might be in the page content.

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesPHP Development > How to collect all html tags of a page into one large array?

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