Jump to content


Photo

read between the selected tag


  • Please log in to reply
4 replies to this topic

#1 greenba

greenba
  • Members
  • PipPipPip
  • Advanced Member
  • 31 posts
  • LocationBosnia and Herzegovina

Posted 20 September 2006 - 12:11 AM

Hi,

I have the following string:
"
<div class="style1">Company</div>
"
How can I get just the "Company"?

Any ideas?

regards,

#2 Tandem

Tandem
  • Members
  • PipPipPip
  • Advanced Member
  • 251 posts

Posted 20 September 2006 - 12:14 AM

strip_tags() will remove any html tags from a string if thats what you need.

#3 greenba

greenba
  • Members
  • PipPipPip
  • Advanced Member
  • 31 posts
  • LocationBosnia and Herzegovina

Posted 20 September 2006 - 12:16 AM

That is OK, but I have many different tabs so i cannot just strip tags.
this is what I have:
"
<div class="style1">Company</div>
<div class="style1">name</div>
<div class="style1">age</div>
"

#4 Tandem

Tandem
  • Members
  • PipPipPip
  • Advanced Member
  • 251 posts

Posted 20 September 2006 - 01:42 AM

Sorry i'm not sure about that, however i would quite like to know how too, so i would also appreciate it if anybody could explain.

#5 effigy

effigy
  • Staff Alumni
  • Advanced Member
  • 3,600 posts
  • LocationIL

Posted 20 September 2006 - 02:04 AM

<pre>
<?php
   $data = <<<DATA
	<div class="style1">Company</div>
	<div class="style1">name</div>
	<div class="style1">age</div>
DATA;
   preg_match('%^\s+<div.*?>(.+?)</div>%', $data, $matches);
   echo $matches[1];
?>

Regexp | Unicode Article | Letter Database
/\A(e)?((1)?ff(?:(?:ig)?y)?|f(?:ig)?)\z/




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users