note 85737 added to security.magicquotes.whynot

From: Date: Mon, 15 Sep 2008 17:26:10 +0000
Subject: note 85737 added to security.magicquotes.whynot
Groups: php.notes 
Request: Send a blank email to php-notes+get-144426@lists.php.net to get a copy of this message
<?php //One could use array_walk, altough i think it was fun //and simple doing it this way. class oop { //toObject : Transforms an array into an object filtering it //$source : Array to transform //$currentLevel : See $maxLevels //$maxLevels : Protect the system in case of lots of recursion // i.e. <input type="text" name="test[][]....[N]" public static function toObject($source=array(),$array=array(),$maxLevels=3,$currentLevel=0) { if ( !sizeof($source) || ($currentLevel > $maxLevels) ) return FALSE; $array = (sizeof($array)) ? $array : $source; $obj = new stdClass(); foreach ($array as $k => $v){ if (is_array($v)) { $obj->$k = self::toObject($source,$v,$maxLevels,++$currentLevel); continue; } //Assign to the object $obj, the key and the value of the actual value of $source $obj->$k=$v; } return $obj; } } /* Eexamples $post = oop::toObject($_POST) ; $get = oop::toObject($_GET) ; $session = oop::toObject($_SESSION); var_dump ($post) ; var_dump ($get) ; var_dump ($session); */ ?> ---- Server IP: 201.216.232.3 Probable Submitter: 190.220.69.142 ---- Manual Page -- http://www.php.net/manual/en/security.magicquotes.whynot.php Edit -- https://master.php.net/note/edit/85737 Del: integrated -- https://master.php.net/note/delete/85737/integrated Del: useless -- https://master.php.net/note/delete/85737/useless Del: bad code -- https://master.php.net/note/delete/85737/bad+code Del: spam -- https://master.php.net/note/delete/85737/spam Del: non-english -- https://master.php.net/note/delete/85737/non-english Del: in docs -- https://master.php.net/note/delete/85737/in+docs Del: other reasons-- https://master.php.net/note/delete/85737 Reject -- https://master.php.net/note/reject/85737 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#144426) next »