STRING :
$string = '{$string#anything#something this string will output default |ucfirst|strtoupper}';
PREG_REPLACE_CALLBACK CODE(PHP) :
$string = preg_replace_callback('/\{\$?([^# ]+)\#?([^ ]+)? ?([^|]+)?[ \|]?([^\}]+)?\}/', $matches, $string);
OUTPUT($matches) :
Array
(
[0] => {$string#anything#something can you hear me? |ucfirst|ucfirst|ucfirst|strtoupper}
[1] => string
[2] => anything#something
[3] => can you hear me?
[4] => ucfirst|strtoupper
)
REQUIREMENT : in place of {$string this string will output default |ucfirst|strtoupper}
, i want to use {$string this string will output default ucfirst|strtoupper}
(notice:pipe sign in front of ucfirst
is removed);
IMPORTANT : output(ie $matches array) should look same as printed above.
Your help will be much appreciated, thanks for reading.