Troubleshooting a recursive stripslashes method in PHP
<p>I'm trying to use the stripslashes_deep function in the PHP documentation as a method, but when I pass it an array, it doesn't work. It does, however, work with a string. Can anyone point out why it might not be working? Magic quotes are on because I'm testing for that possibility, but like I said, it works for a string and I'm also not testing $_POST, or $_GET data. Here's the code:</p>

<pre><code>protected function stripslashes_deep($input){
 return is_array($input) ? array_map($this-&gt;stripslashes_deep, $input) : stripslashes($input);
}
</code></pre>

<p>The string 'O\'Reilly' is converted to 'O'Reilly', but the array below remains unchanged:</p>

<p>Array ( [0] => Array ( [userId] => 23 [0] => 23 [username] => O\'Reilly [1] => O\'Reilly [userFirstName] => Bill [2] => Bill [userLastName] => O\'Reilly [3] => O\'Reilly ) ) </p>

<p>Any help would be greatly appreciated.</p>

<p>Edit:</p>

<p>The array is coming from the database and has slashes because it was inserted with bound parameters by the PDO object. I extended PDO and I'm trying to strip the slashes automatically when I fetch the array so I don't have to call stripslashes every single time I output data. If anyone knows of a better way to do that, I'm definitely open to suggestions. I didn't see any sort of unquote method for PDO.</p>
