rashmi_k28 Posted October 7, 2008 Share Posted October 7, 2008 hi, I have the code : function getdata(){ $values=array(); for ($i = 0; $i < 4; $i++) { $value[$i] = array(-1,-1,-1,-1); } $sql = "select * from table1"; $result = mysql_query($sql); while($row = mysql_fetch_array($result)){ $value[$row[0]][0] = $row[1]; $value[$row[0]][1] = $row[2]; $value[$row[0]][2] = $row[3]; $value[$row[0]][3] = $row[4]; } return $values; } When I call the function $data=getdata(); How to take each $value[$row[0]][0] as the separate array Link to comment https://forums.phpfreaks.com/topic/127365-array/ Share on other sites More sharing options...
Orio Posted October 7, 2008 Share Posted October 7, 2008 You haven't supplied the full code.. There's no return statement in your function in the given code. It'd be easier if you'd show the full code.. Orio. Link to comment https://forums.phpfreaks.com/topic/127365-array/#findComment-658884 Share on other sites More sharing options...
rashmi_k28 Posted October 7, 2008 Author Share Posted October 7, 2008 Hi, When I execute the $sql statement I get the around 200 values. $sql="select time,field1,field2 from table"; here I want to copy all the 3 fields into an single array. When I call the function in another page I want `time` and `field1` and `field2` as a separate arrays again. How can I do it from a single array. Link to comment https://forums.phpfreaks.com/topic/127365-array/#findComment-658901 Share on other sites More sharing options...
waynew Posted October 7, 2008 Share Posted October 7, 2008 2D arrays. Use them. Link to comment https://forums.phpfreaks.com/topic/127365-array/#findComment-658941 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.