note 91035 deleted from function.str-replace by cmb

From: Date: Sun, 15 Sep 2019 14:47:44 +0000
Subject: note 91035 deleted from function.str-replace by cmb
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-212210@lists.php.net to get a copy of this message
Note Submitter: moz667 at gmail dot com ---- <?php /* This is a function for made recursive str_replaces in an array */ function recursive_array_replace($find, $replace, &$data) { if (is_array($data)) { foreach ($data as $key => $value) { if (is_array($value)) { recursive_array_replace($find, $replace, $data[$key]); } else { $data[$key] = str_replace($find, $replace, $value); } } } else { $data = str_replace($find, $replace, $data); } } $a = array(); $a['a'] = "a"; $a['b']['a'] = "ba"; $a['b']['b'] = "bb"; $a['c'] = "c"; $a['d']['a'] = "da"; $a['d']['b'] = "db"; $a['d']['c'] = "dc"; $a['d']['d'] = "dd"; echo "Before Replaces"; print_r($a); recursive_array_replace("a", "XXXX", $a); echo "After Replaces"; print_r($a); ?>

« previous php.notes (#212210) next »