<?php $mobile = '123456789'; $pattern = '(xx)-xxxxxxx'; echo preg_replace_callback('/x+/', function ($match) use (&$mobile) { $length = strlen($match[0]); $replacement = substr($mobile, 0, $length); $mobile = substr($mobile, $length); return $replacement; }, $pattern);
You have javascript disabled. You will not be able to edit any code.