Hello i want get data in array from the database, i have this code:
$sql = "SELECT * FROM nat WHERE village = '$village'";
$result = $conn->query($sql);
$prname1=array();
while($row = $result->fetch_array()) {
$prname1[]=$row['id_source'];
}
if call print_r
print_r($prname1);
get back this value:
Array ( [0] => 30000 [1] => 30002 [2] => 30003 )
I need values like this:
[ [0 => 30000], [0 => 30002], [0 => 30003], ]
how to? Thanks
I try more solutions
CodePudding user response:
Wrap another array around the value when pushing onto the result array.
$prname1[] = [$row['id_source']];