mysql - How can i get Array values to separate php variables -


i trying retrieve records in mysql db.i want retrieve records belong img_path column.from following code getting results array.but iw ant them separate variables.

my code

$result_list = array(); while($row = mysqli_fetch_array($query)) {     $result_list[] = $row; } foreach($result_list $row) {      $productitems[] = array(         'img_path' => $row['img_path'],     );  }  print_r($productitems); 

current output

array (  [0] => array ( [img_path] => img/8041171eda3a8fddf508bfd0d9a0866e1472441466.png )  [1] => array ( [img_path] => img/91882b5f9ffa624a9dc81dfa0ec980861472441077.jpg )  [2] => array ( [img_path] => img ) ) 

expected output

$variable1 = img/8041171eda3a8fddf508bfd0d9a0866e1472441466.png; $variable2 = img/91882b5f9ffa624a9dc81dfa0ec980861472441077.jpg; 

you can use extract function this:

$result_list = array(); while($row = mysqli_fetch_array($query)) {     $result_list[] = $row; } foreach($result_list $row) {     $productitems[] = $row['img_path']; } extract($productitems, extr_prefix_all, "variable"); echo $variable_0; echo $variable_1; echo $variable_2; 

Comments

Popular posts from this blog

amazon web services - S3 Pre-signed POST validate file type? -

c# - Check Keyboard Input Winforms -