[ create a new paste ] login | about

Link: http://codepad.org/fCbfkwXn    [ raw code | output | fork ]

PHP, pasted on Jan 21:
1
2
3
4
5
6
7
8
9
<?php
$string = "string_key::%foo%:%bar%";
$params = array("foo" => 1, "bar" => 2);
foreach($params as $key => $value) {
    $search[] = "%" . $key . "%";
    $replace[] = $value;
}
$output = str_replace($search, $replace, $string);
echo $output;


Output:
1
string_key::1:2


Create a new paste based on this one


Comments: