Snippets v2

Languages
My Snippets

Stripslashes on Arrays Login or Register to Bookmark this snippet

Description PHP

This function will recursively stripslashes from any string branch of an array.

The Code Download
  1. <?php
  2. function stripslashesArray($arr) {
  3.     if (is_array($arr)) {
  4.         $keys = array_keys($arr);
  5.         for ($x=0;$x<count($keys);$x++) {
  6.             if (!is_object($arr[$keys[$x]])) {
  7.                 $arr[$keys[$x]] = stripslashesArray($arr[$keys[$x]]);
  8.             }
  9.         }
  10.         return $arr;
  11.     } else {
  12.         return stripslashes($arr);
  13.     }
  14. }
  15. ?>
Credits Contact JC

Added by JC on 12th November, 2007

Comments

There are no comments about this snippet.

Post Comment HTML is allowed

You must be registered and logged in to post a comment.

Login here to post a comment