How can I replace something orderly? for example:
$var = "let's count: ?, ?, ?";
Now I want to replace it by 1, 2, 3 for the result to be "let's count 1, 2, 3". How can I do that? I can't replace by "%s" and use vsprintf() with an array because I wanna respect integers and floats. But I want to do it with an array. For example:
$var = replace( $var, "?", array(1, 2, 3) );
How can I do it? I can't get any idea.
How about:
$var = "let's count: ?, ?, ?";
$numbers = array(1,2,3);
foreach( $numbers as $number ) {
$var = preg_replace("/\?/", $number, $var, 1);
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With