Can I make an associative array from two columns? I want column A as key and column B as value.
-------------
| id | name |
-------------
| 1 | sky |
-------------
| 2 | space |
I want a function that make result like this:
$ary=array('1'=>'sky','2'=>'space', ... );
Is any php function exist about this matter?
I'm using php, mysql and codeigniter.
$ary = array();
while ($row = $stmt->fetch_assoc()) {
$ary[$row['id']] = $row['name'];
}
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