php array to query code example
Example 1: php http build query
$data = [
'foo' => 'bar',
'baz' => 'boom',
'cow' => 'milk',
'php' => 'hypertext processor'
];
echo http_build_query($data);
echo http_build_query($data, '', '&');
Example 2: php create url with query sting from array
<?php
$data = array(
'foo' => 'bar',
'baz' => 'boom',
'cow' => 'milk',
'php' => 'hypertext processor'
);
echo http_build_query($data) . "\n";
echo http_build_query($data, '', '&');
?>
Example 3: convert query result to array php
$result = "select * from random_table where id = 1";
$rows = [];
while($row = mysqli_fetch_array($result))
{
$rows[] = $row;
}