Re[2]: [PHP] retrieve data from multidimensional array

From: Date: Sat, 20 Jul 2002 17:35:18 +0000
Subject: Re[2]: [PHP] retrieve data from multidimensional array
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-108667@lists.php.net to get a copy of this message
Hello Jason, It might work but I can not for the life of me figure out how to use it to get the data. Below is what I have so far but don't know where to go from there If I search for a word that is in $row_1 I what it return every line that it is in and there will usually be more than one. This is a virtusertable table for sendmail that I am searching. I need to retrieve data change data and delete data with this script. So far all I have done is separate the data so I can do something with it. I don't know maybe I am going at this all wrong if somebody has a better idea please let me know function bs_file($filename) { $fp = @fopen($filename, "r"); if (!($fp)) { return 0; } while (!feof($fp)) { $temp .= fread($fp, 4096); } $arr = explode("\n", $temp); return $arr; } $filename="./etc/virtusertable"; $file=bs_file($filename); for($i = 0; $i < count($file); $i++){ $value = $file[$i]; $arra = explode(" ", $value); <-this is searching on a tab $row_0 = $arra[0]; $row_1 = $arra[1]; $multi=array($row_0,$row_1); echo "$multi[0]&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$multi[1]<br>"; } Saturday, July 20, 2002, 2:33:32 AM, you wrote: JW> On Saturday 20 July 2002 15:49, rdkurth@starband.net wrote: >> I have a multidimensional array. How can I search and retrieve all data >> that is like $value from it. >> the array looks like this $multi=array($row_0,$row_1); I want to >> retrieve all data where $value matches $row_1 and display the data on >> the screen. I know that array_search and in_array will tell me that >> the data exist but I what to retrieve it. JW> Doesn't array_search() do what you want? Presumably if you're searching for JW> something you know what you're searching for then all you need to know is JW> where it is found. -- Best regards, rdkurth mailto:rdkurth@starband.net

« previous php.general (#108667) next »