php替换完整的数字[重复]

This question already has an answer here:

Hi hope somebody can help me, I have the following code but I send $data = 11, it sends me a 1010 instead of 100, is replacing the '1' two times, does anybody know how to fix this? thanks

$search = ['1','2','3','11','12','13'];
$replace = ['10','25','50','100','250','500'];
return str_replace($search, $replace, $data);
</div>

Try to make the reverse order and use a foreach with a $count check like the following:

$search = ['13','12','11','3','2','1'];
$replace = ['500', '250', '100','50','25','10'];
for($i=0, $count=0; $i<count($search); $i++) {
    $data = str_replace($search[$i], $replace[$i], $data, $count);
    if ($count) {
       return $data;
    }
}