0

I developed code for get mysql table data.

$latvalue = Array();
    $logvalue = Array();

    while ($row = mysqli_fetch_array($resultstore, MYSQL_ASSOC)) {
    $latvalue[] = $row['lat']; 
    $logvalue[] = $row['log']; 
}  

So its like (45 ,56,34) (10 ,20,30) for example

I want to combine those 2 arrays into one 2 dimensional array.

Example

 $data = array
 (
   0 => array(45, 10),
  1 => array(56, 20),
  2 => array(34, 30),
  );  

I can't figure out logic to do this. Please help.

1
  • If you do a SELECT lat, long ... then you just do: $data[] = $row; in the loop. Or just while ($data[] = mysqli_fetch_array($resultstore, MYSQL_ASSOC)) { Commented Feb 9, 2016 at 19:20

1 Answer 1

2

You can change your code to do it:

$latlong = array();

while ($row = mysqli_fetch_array($resultstore, MYSQL_ASSOC)) {
    $latlong[] = array($row['lat'], $row['log']);
} 
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.