Jump to content
MoFish

Parse String Help

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

Share this post


Link to post
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.

}
  • Like 1

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • 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.