<?php
$original = 'some od or perhaps a #ph in this :rn:';
$abbreviation= array();
$abbreviation[0] = 'od';
$abbreviation[1] = 'rn';
$abbreviation[2] = 'ph';
$abbreviation[3] = 'real';
$translated= array();
$translated[0] ='odometer';
$translated[1] ='run';
$translated[2] ='pinhole';
$translated[3] ='fake';
function add_regex_finders($str){
return "/([\s:\#])" . $str . "([\s:])/i";
}
$original_parsed = array_map('add_regex_finders',$abbreviation);
echo preg_replace($original_parsed, array_map(function ($v) { return '$1' . $v . '$2'; }, $translated), $original);
- Output for 7.2.0 - 7.2.33, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.33, 8.2.0 - 8.2.29, 8.3.0 - 8.3.25, 8.4.1 - 8.4.12
- some odometer or perhaps a #pinhole in this :run:
preferences:
125.11 ms | 407 KiB | 5 Q