note 77071 added to ref.array

From: Date: Mon, 13 Aug 2007 22:41:17 +0000
Subject: note 77071 added to ref.array
Groups: php.notes 
Request: Send a blank email to php-notes+get-129457@lists.php.net to get a copy of this message
look... this is my code: <? function searchstoreconcpt($yyear,$awcostt){ $j; for($j=0; $j<=sizeof($awcostt);$j++) { if($awcostt[$j]["yyear"] == $yyear) break; } if($j > sizeof($awcostt)) { $awcost[$j]["yyear"] = $yyear; return $awcost[$j]; } else { $awcostt[$j]["yyear"] .= " + 1"; return $awcostt[$j]; } } ?> <pre> <? $i=1; $awcost; $awcost[$i++] = searchstoreconcpt(2003,$awcost); $awcost[$i++] = searchstoreconcpt(2003,$awcost); $awcost[$i++] = searchstoreconcpt(2002,$awcost); $awcost[$i++] = searchstoreconcpt(2003,$awcost); $awcost[$i++] = searchstoreconcpt(2003,$awcost); $awcost[$i++] = searchstoreconcpt(2001,$awcost); print_r($awcost); ?> </pre> and this is my result: Array ( [1] => Array ( [yyear] => 2003 ) [2] => Array ( [yyear] => 2003 + 1 ) [3] => Array ( [yyear] => 2002 ) [4] => Array ( [yyear] => 2003 + 1 ) [5] => Array ( [yyear] => 2003 + 1 ) [6] => Array ( [yyear] => 2001 ) [7] => Array ( [yyear] => 2002 + 1 ) ) but... I want this result.... Array ( [1] => Array ( [yyear] => 2003 +1 +1 +1 ) [2] => Array ( [yyear] => 2002 +1 +1 ) [3] => Array ( [yyear] => 2001 ) ) I don't know if you can help me, please, i'm waitting for your answer ---- Server IP: 69.147.83.197 Probable Submitter: 201.155.28.241 ---- Manual Page -- http://www.php.net/manual/en/ref.array.php Edit -- https://master.php.net/note/edit/77071 Del: integrated -- https://master.php.net/note/delete/77071/integrated Del: useless -- https://master.php.net/note/delete/77071/useless Del: bad code -- https://master.php.net/note/delete/77071/bad+code Del: spam -- https://master.php.net/note/delete/77071/spam Del: non-english -- https://master.php.net/note/delete/77071/non-english Del: in docs -- https://master.php.net/note/delete/77071/in+docs Del: other reasons-- https://master.php.net/note/delete/77071 Reject -- https://master.php.net/note/reject/77071 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#129457) next »