-1

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??

3 Answers3

1
$myArray = array(1,4,6);

$num1 = $myArray[0];
$num2 = $myArray[1];
$num3 = $myArray[3];

echo $num1; // 1
echo $num2; // 4
echo $num3; // 6
Branko
  • 149
  • 6
0

Use this

list($first,$second) = $array;
Waleed Ahmed Haris
  • 1,229
  • 11
  • 17
0

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;
}
Passionate Coder
  • 7,154
  • 2
  • 19
  • 44