[Solved] Need a preg_replace or best option for this conversion [closed]


Your question is very unclear and I may be way off, but here is my attempt to your question.

$link = array('S1, Ep1', 'S1, Ep2', 'S1, Ep3', 'S1, Ep10');

$results = preg_replace_callback('~^S(\d+)\D+(\d+)$~m', 
         function($m) {
            $which = strlen($m[2]) > 1 ? '00' : '000';
            return $m[1] . $which . $m[2];
         }, array_values($link));

print_r($results);

Output

Array
(
    [0] => 10001
    [1] => 10002
    [2] => 10003
    [3] => 10010
)

5

solved Need a preg_replace or best option for this conversion [closed]