I have no idea how this is done.

But, Wordpress and some other scripts use tags like {something}

inside of a text box... and the {sometime} becomes a PHP variable...

hope someone knows what I mean here, not really even sure how to ask!

but hoping to figure out how to do this...

    $text = 'Why hello there {name}, how are you today?';
    $name = 'Brad';
    
    $text = str_replace('{name}', $name, $text);
    echo $text; // Why hello there Brad, how are you today?

    Or were you looking for something more generic? If so, you could do a [man]preg_match_all/man to find all occurrences of {something} (where 'something' looks like whatever you want, e.g. a valid PHP variable name). You could then walk through the array of matches and use [man]isset/man to determine if a PHP variable exists and, if so, [man]str_replace/man the placeholder with its value.

      There are various templating engines out there that use a similar syntax. Probably the most popular is Smarty, which to simply output a PHP variable uses something like:

      <p>Hello, {$username}.</p>
      

      This is not built-in functionality for PHP -- you would need to download and include Smarty to have it parse such template files.

        Write a Reply...