I have a PHP array of strings, which I would like to postfix with a character. below regular expression to add something prefix of each array elements:
$prefixed_array = preg_filter('/^/', 'prefix_', $array);
But, I need add postfix.
Essentially I would like to go from this:
$array = ["a", "b", "c", "d", "f"];
To this:
$array = ["a_M", "b_M", "c_M", "d_M", "f_M"];
I can do it with foreach
, but need a regular expresion (Just Regex).