twisted-dev twisted-dev - 28 days ago 4
MySQL Question

how to break array to obtain an individual data from it?

Well I have this array which has data in

Array
(
[0] => 1
[1] => 4
)


the 1 and 4 are the id of data in the database
now I want the data 1 4 individually so that I can compare it with the id of other datas in the database when running a query.
I am new can anyone help me??

Answer

You can access it directly like this

$data = array(1,4);
echo $data[0];// 1
echo $data[1];// 4

or dynamically

foreach($data as $id){

echo $id;
}
Comments