A simple regex will do the trick:
$thenewtext = preg_replace('#\*{2}(.*?)\*{2}#', '<b>$1</b>', '**Hello World** of PHP');
More Related Contents:
- PHP string replace match whole word
- PHP explode the string, but treat words in quotes as a single word
- When to use strtr vs str_replace?
- Str_replace for multiple items
- Replace string in an array with PHP [closed]
- str_replace with array
- swap two words in a string php
- How to replace multiple values in php
- How to replace multiple items from a text string in PHP? [duplicate]
- Simple: How to replace “all between” with php? [duplicate]
- URL rewriting with PHP
- Why does PHP consider 0 to be equal to a string?
- Many-to-many relationships examples
- including a remote file in PHP
- On delete cascade with doctrine2
- php date validation
- How to alias a table in Laravel Eloquent queries (or using Query Builder)?
- Do login forms need tokens against CSRF attacks?
- Fastest way to add prefix to array keys?
- mySQLi prepared statement unable to get_result()
- Check if specific input file is empty
- MySQL Performance – “IN” Clause vs. Equals (=) for a Single Value [duplicate]
- PHP: Split string into array, like explode with no delimiter
- MySQL skipping first row
- Creating anonymous objects in php
- Group array values based on key in php? [duplicate]
- How do you use PHPUnit to test a function if that function is supposed to kill PHP?
- preg_match with international characters and accents
- Add a custom checkbox in WooCommerce checkout which value shows in admin edit order
- PHP Find all occurrences of a substring in a string