I can get along with regex when needed, but for some reason I am in the dark trying to figure out why preg_replace cuts off leading digit or space.
Example:
$phone = '00 385 1234567';
$sig = 'abcd <span id="phone"></span> efgh';
$text = preg_replace('/(<span[^>]*id="phone".*)(.*?)(<\/span>)/smi', '$1'.$phone.'$3', $sig);
echo $text;
First 0 is missing in result, also if there is any digit or space (or maybe some other sign as well), but not if first is a character or sign + and others. Can someone shed some light on this behaviour please?