this is really a silly question to ask but i would like to know for the below condition which loop will be best to use? foreach or for loop?
$ids = array(1,2,3,4,5);
$query = 'INSERT INTO blah(id) VALUES ';
for($i=1; $i<=count($ids); $i++) {
$query .= ' ( ? , ?) , ';
}
OR
foreach($ids as $id) {
$query .= ' ( ? , ?) , ';
}
Foreach is more concise in this case.