Array_walk

From: Date: Mon, 26 Jun 2000 19:34:25 +0000
Subject: Array_walk
Groups: php.general 
Request: Send a blank email to php-general+get-3181@lists.php.net to get a copy of this message
Hey All I have an array of id numbers on which I use the array_walk to search a database of the for the relevant price and description of the id. What I want to do is return the total price for all the id numbers in the array. Anyone know how to do that or maybe a better way. The code is below.. function bookarraycheck($item) { global $conn_id; $result = ifx_query("select title, price from books where bookid = '$item'",$conn_id); $r = ifx_fetch_row($result); ifx_free_result ($result); echo "<TR><TD WIDTH=\"50%\" VALIGN=\"TOP\">".$r["title"]."</TD>"; echo "<TD WIDTH=\"50%\" VALIGN=\"TOP\">£ ".$r["price"]."</TD></TR>"; $totalcosts += $r["price"]; return $totalcosts; } array_walk( $book, 'bookarraycheck' ); Thanks Phil Caint.com

« previous php.general (#3181) next »