PHP Salt


A little dash of PHP... my collection of php functions

Version: 2.34.4
Last Build: March 13, 2025 23:10pm (PST)

Main Menu

Home

Get PHP Salt


The Functions

array
db
file
graph
html
mail
math
misc
mobile
script
string
system
time
web
psStrReplaceList()
Replace a list (key/val array) in a string


Description:

Returns a string with all the key/val pairs from an array replaced



Usage:

$str = psStrReplaceList($string,$array);



Example:


$ary['_color_'] = "red";
$ary['_sku_'] = "23423";

$template = "SKU: _sku_ / Color: _color_";

$str = psStrReplaceList($template,$ary);





Code:

function psStrReplaceList($str,$ary)
{
foreach ($ary as $key=>$val)
{
$str = str_replace($key,$val,$str);
}
return $str;
}

Changlelog:


See Also

And a shot out to:

PHP - php.net
Fedora Server - getfedora.com
Shameless ads to pay for site