Jump to content

Parse String Help


MoFish

Recommended Posts

Hi All,

 

I have mark-up which contains many {{edit:xxx}} tags this is inside a variable called $html

 

I'm trying to find all these edit tags and displaying the name, but am not sure best how to achive it.

 

For example my $html contains:

{{edit:top}}
{{edit:bottom}}
{{edit:left}}
{{edit:right}}

I want to create a $results array with the following values:

top
bottom
left
right

Many thanks,

 

MoFish

Link to comment
Share on other sites

You can achieve this with preg_match_all 

$success = preg_match_all("/{{edit:(.*?)}}/i", $html, $results);

if ($success)
{
  $results = $results[1];

  //$results now contains all your edit values, you can do what you want with them.

}
Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.