Snippets v2

Languages
My Snippets

Addslashes on Arrays Login or Register to Bookmark this snippet

Description PHP

This function will recursively addslashes to any string branch of an array.

The Code Download
  1. <?php
  2. function addslashesArray($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]] = addslashesArray($arr[$keys[$x]]);
  8.             }
  9.         }
  10.         return $arr;
  11.     } else {
  12.         return addslashes($arr);
  13.     }
  14. }
  15. ?>
Credits Contact JC

Added by JC on 11th 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