| 1085 | |
| 1086 | /** |
| 1087 | * Navigates through an array and add slashes to escape the values. |
| 1088 | * |
| 1089 | * If an array is passed, the array_map() function causes a callback to pass the |
| 1090 | * value back to the function. This value will be slash-escaped. |
| 1091 | * |
| 1092 | * @param array|string $value The array or string to be escaped |
| 1093 | * @return array|string Escaped array (or string in the callback). |
| 1094 | */ |
| 1095 | function addslashes_deep($value) { |
| 1096 | if ( is_array($value) ) { |
| 1097 | $value = array_map(array(&$this, 'addslashes_deep'), $value); |
| 1098 | } elseif ( is_object($value) ) { |
| 1099 | $vars = get_object_vars( $value ); |
| 1100 | foreach ($vars as $key=>$data) { |
| 1101 | $value->{$key} = addslashes_deep( $data ); |
| 1102 | } |
| 1103 | } else { |
| 1104 | $value = addslashes($value); |
| 1105 | } |
| 1106 | |
| 1107 | return $value; |
| 1108 | } |