note 72006 added to ref.array

From: Date: Thu, 28 Dec 2006 18:52:25 +0000
Subject: note 72006 added to ref.array
Groups: php.notes 
Request: Send a blank email to php-notes+get-120987@lists.php.net to get a copy of this message
public domain, yadda yadda. :) This function takes a flatfile-like array (like the results of a joined query) and normalizes it based on whichever parameters you like. <?php function hashByFields($things,$fields) { $retval=null; $count = count($fields); foreach ($things as $thing) { $fwibble =& $retval; for ($j=0;$j<$count;$j++) { $val = $thing[$fields[$j]]; if ($j == $count - 1) { $fwibble[$val] = $thing; } else if (!isset($fwibble[$val])) { $fwibble[$val] = Array(); } $fwibble =& $fwibble[$val]; } } return $retval; } ?> ---- Server IP: 66.163.161.117 Probable Submitter: 76.167.62.172 ---- Manual Page -- http://www.php.net/manual/en/ref.array.php Edit -- https://master.php.net/note/edit/72006 Del: integrated -- https://master.php.net/note/delete/72006/integrated Del: useless -- https://master.php.net/note/delete/72006/useless Del: bad code -- https://master.php.net/note/delete/72006/bad+code Del: spam -- https://master.php.net/note/delete/72006/spam Del: non-english -- https://master.php.net/note/delete/72006/non-english Del: in docs -- https://master.php.net/note/delete/72006/in+docs Del: other reasons-- https://master.php.net/note/delete/72006 Reject -- https://master.php.net/note/reject/72006 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#120987) next »