<?php $str = "1,2,3"; $array = [ "1" => "apple", "2" => "banana", "3" => "orange" ]; echo preg_replace_callback( '/\d+/', fn($m) => $array[$m[0]] ?? $m[0], $str );
You have javascript disabled. You will not be able to edit any code.