PHP implements array recursive escape, and php array recursive escape. PHP implements array recursive escape. This article describes how php implements array recursive escape in the form of an example. For example, PHP implements array recursive escape and php array recursive escape.
This article describes how to implement recursive escape of arrays in PHP in the form of examples and shares it with you for your reference. The specific method is as follows:
The main function code is as follows:
$ Arr = array ('a "AA', array (" c 'd ", array ('E" f'); function changes ($ arr) {foreach ($ arr as $ k =>$ v) {if (is_string ($ v) {$ arr [$ k] = addslashes ($ v );} else if (is_array ($ v) {// escape if it is an array. $ arr [$ k] = changes ($ v) ;}return $ arr;} print_r (changes ($ arr ));
I hope this article will help you with PHP programming.
PHP recursively changing the values of two-dimensional arrays
// Check the method first. Otherwise, the public function check ($ result, $ arr, $ r) {$ re = $ r; foreach ($ result as $ value) {if ($ arr [$ re] ['name'] = $ value ['name'] | $ arr [$ re] ['uid'] = $ value ['uid']) {$ re = $ re + 1; $ this-> check ($ result, $ arr, $ re) ;}} return $ re ;} // the following main method is public function xxxxxxxxxxxxxxxx () {$ arr = array ('id' => 1, 'name' => 'AAA ', 'uid' => 1), array ('id' => 2, 'name' => 'BBB ', 'uid' => 2 ), array ('id' => 3, 'name' => 'CCC ', 'uid' => 3), array ('id' => 4, 'name' => 'ddd ', 'uid' => 4), array ('id' => 5, 'name' => 'CCC ', 'uid' => 3), array ('id' => 6, 'name' => 'BBB ', 'uid' => 2 ), array ('id' => 7, 'name' => 'BBB ', 'uid' => 2), array ('id' => 8, 'name' => 'fff', 'uid' => 6), array ('id' => 9, 'name' => 'CCC ', 'uid' => 3), array ('id' => 10, 'name' => 'BBB ', 'uid ...... remaining full text>
Recursive key name of php multi-dimensional array
Try the blind write capability
$ A = // original array;
$ B = array ();
Foreach ($ a as $ k => $ v)
$ B [intval ($ v ['id'])] = $ v ['unit _ name'];
$ A = $ B;
Print_r ($ a); // $ a is the modified joined array
In this article, examples are provided to illustrate how PHP implements recursive escape of arrays. The specific method is as follows...