Skip to content
Advertisement

Tag: multidimensional-array

How can I recursively search for and replace values inside of an unknown-depth multidimensional PHP array?

I’m working with a JSON string. I’m converting it to an associative array to find specific values and change those values when a certain key is found ([‘content’]). The depth of the array is always unknown and will always vary. Here is the function I wrote. It takes an array as an argument and passes it by reference so that

PHP wrong foreach code

What I have done wrong, foreach code written below, but it seems not working: What I have to change in this foreach code? Thanks Answer first line, custom is not a variable (could be copy and paste error) Then you are splitting a string using can array operator, you need to split that string first using: Then, you have declared

Sanitize & desanitize multidimensional array

I have the following class I wrote: The problem is that while it works on strings and one-dimensional arrays, I get the following error with multidimensional arrays: Warning: htmlspecialchars() expects parameter 1 to be string, array given in C:wampwwwclassesSanitizer.php on line 10 How do I fix this? Any help would be greatly appreciated. Answer Your code was not evaluating array

Advertisement