Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7056125
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T03:49:49+00:00 2026-05-28T03:49:49+00:00

I’m using this with success $str = {source}do_something; if(substr($str, 0, 8) == {source}) but

  • 0

I’m using this with success

$str = "{source}do_something";
if(substr($str, 0, 8) == "{source}")

but what should I do if I’ve

$str = "<br><br>{source}do_something";

the goal is to be able of adding blank lines (as many as needed) before firing up my do_something

Thanks

EDIT

ok, so I need to run the function

menu;vertical,true

but I also need to have those blank lines before my menu

my string is

<br><br><br><div>{source}_menu_;vertical,true{/source}</div>

with no line breaks I use

if(substr($pos, 0, 8) == "{source}") {
    $campos = substr_replace($description, '', 0, 8);
    $campos = substr($campos, 0, -9);
    $funcao = explode(";", $campos);
    call_user_func_array($funcao[0], array($funcao[1]));
}

now I need the same thing but with the line breaks, so the browser actually renders line breaks and then runs the function.

I hope my english is good enough to make this clear…

Thanks

NEW EDIT with solution

$startTag = "{source}";
$endTag = "{/source}";
$initial_strpos = strpos($str, $startTag);
$final_strpos = strpos($str, $endTag);
if ($initial_strpos !== false) {
    $beforeTag = substr($str, 0, $initial_strpos);
    echo htmlspecialchars_decode($beforeTag, ENT_QUOTES);
    $start = $initial_strpos + strlen($startTag);
    $innerText = substr($str, $start, strpos($str, $endTag)-$start);
    $funcao = explode(";", $innerText);
    call_user_func_array(array_shift($funcao), $funcao);
    $aferTag = strpos($str, $final_strpos);
    echo htmlspecialchars_decode($aferTag, ENT_QUOTES);
}

this will print my line breaks and run my function.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T03:49:50+00:00Added an answer on May 28, 2026 at 3:49 am

    If you have to check the first 8 characters specifically, then you should remove the <br>s from the string before doing the substring:

    if (substr(str_replace("<br>", "", $str), 0, 8) == "{source}")
    

    This won’t work if the string is slightly different, i.e. <br />. The best way to do this would probably be:

    if (strpos($str, "{source}") !== false)
    

    EDIT

    How about this? It should get the text between the {source}{/source} tags and split them by ;, then take the first entry as the function name and the second as parameters to the function.

    $startTag = "{source}";
    $endTag = "{/source}";
    $strpos = strpos($str, $startTag);
    if ($strpos !== false)
    {
        $start = $strpos + strlen($startTag);
        $innerText = substr($str, $start, strpos($str, $endTag)-$start);
        list($functionName, $parameters) = explode(";", $innerText);
        call_user_func_array($functionName, explode(",", $parameters));
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I want to count how many characters a certain string has in PHP, but
link Im having trouble converting the html entites into html characters, (&# 8217;) i
For some reason, after submitting a string like this Jack’s Spindle from a text
I am reading a book about Javascript and jQuery and using one of the
this is what i have right now Drawing an RSS feed into the php,
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.