note 48564 added to function.array

From: Date: Wed, 29 Dec 2004 19:54:59 +0000
Subject: note 48564 added to function.array
Groups: php.notes 
Request: Send a blank email to php-notes+get-82467@lists.php.net to get a copy of this message
As my need, I've made a function that scan the assoc. array and format every row that is numeric, otherwise dont make nothing. In this example, the function format in Brazillian way, its all about to change it :) <?php function numFrmtAssoc($arrNum){ foreach ($arrNum as $key=>$value){ foreach ($value as $keyAssoc=>$valueAssoc){ if(is_numeric($valueAssoc)) $value[$keyAssoc] = number_format($valueAssoc,'2',',','.'); else $value[$keyAssoc] = $valueAssoc; } } $buffArr[] = $value; return $buffArr; } //usually this array come from a resultset from a database $arr = numFrmtAssoc($AnyAssocArray); echo "<pre>"; print_r($arr); echo "</pre>"; ?> ---- Manual Page -- http://www.php.net/manual/en/function.array.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+48564 Delete -- http://master.php.net/manage/user-notes.php?action=delete+48564&report=yes Reason: bad code -- http://master.php.net/manage/user-notes.php?action=delete+48564&report=yes&reason=bad+code Reason: spam -- http://master.php.net/manage/user-notes.php?action=delete+48564&report=yes&reason=spam Reason: useless example -- http://master.php.net/manage/user-notes.php?action=delete+48564&report=yes&reason=useless+example Reason: contains commercial links -- http://master.php.net/manage/user-notes.php?action=delete+48564&report=yes&reason=contains+commercial+links Reason: useless note -- http://master.php.net/manage/user-notes.php?action=delete+48564&report=yes&reason=useless+note Reject -- http://master.php.net/manage/user-notes.php?action=reject+48564&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#82467) next »