note 75139 added to function.array

From: Date: Tue, 15 May 2007 01:11:32 +0000
Subject: note 75139 added to function.array
Groups: php.notes 
Request: Send a blank email to php-notes+get-126590@lists.php.net to get a copy of this message
I wrote the code below to load values from a query, than save them to two variables, code and text. It is used to replace values using str_replace. The tricky part(for me) was building the two variables from a query. //grab available classes - table of id numbers and //corresponding titles $class_values = mysql_query($sql_classes); // grab avaialable book conditions $condition_values = mysql_query($sql_conditions); // build conversion tables // one for class one for coinditoion $condcode = array(); $condtext = array(); $classcode = array(); $classtext = array(); $i=0; while ($row=mysql_fetch_row($condition_values)){ //echo $row[0]." ".$row[1]; $condcode[$i] =$row[0]; $condtext[$i] =$row[1]; $i++; } $i=0; while ($row=mysql_fetch_row($class_values)){ //echo $row[0]." ".$row[1]; $classcode[$i] = $row[0]; $classtext[$i] = $row[1]; ++$i; } // there is no output, but now four arrays exist . //there are four becuase theycame from two tables // now i call //example: echo str_replace($classcode,$classtext,1); //would output Algebra // ---- Server IP: 69.147.83.197 Probable Submitter: 74.34.0.142 ---- Manual Page -- http://www.php.net/manual/en/function.array.php Edit -- https://master.php.net/note/edit/75139 Del: integrated -- https://master.php.net/note/delete/75139/integrated Del: useless -- https://master.php.net/note/delete/75139/useless Del: bad code -- https://master.php.net/note/delete/75139/bad+code Del: spam -- https://master.php.net/note/delete/75139/spam Del: non-english -- https://master.php.net/note/delete/75139/non-english Del: in docs -- https://master.php.net/note/delete/75139/in+docs Del: other reasons-- https://master.php.net/note/delete/75139 Reject -- https://master.php.net/note/reject/75139 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#126590) next »