I have nooby PHP question that I can't figure out!
I loop through rows from my database:
$data = array();
while($row = sqlsrv_fetch_array($queryResult, SQLSRV_FETCH_ASSOC)){
$data[] = $row;
}
$data now contains an array within an array how can I have it so that its still just a single array?
Thanks all
That's because each $row is an associative array. If you just want data to be an array of values from one column, specify that column:
$data = array();
while($row = sqlsrv_fetch_array($queryResult, SQLSRV_FETCH_ASSOC)){
$data[] = $row['column_name_you_want'];
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With