I have following dynamic $array1:
array(6) { [1]=> string(5) "false"
[2]=> string(5) "true"
[3]=> string(5) "false"
[4]=> string(5) "false"
[5]=> string(5) "true"
[10]=> string(5) "false"
}
- What I would like to do to use loop to create $array2 with $array1 keys where values = "true". So in the end I have:
$array2 = (2, 5);
- And then use this array (with bind_param) to filter my results with "WHERE ... IN ...":
if ($result = $link->prepare("SELECT sapp.appointment_id, sapp.time_start
FROM ss_appointments sapp
WHERE sapp.service_id IN ? AND sapp.time_start >= ?
")) {
$result->bind_param('ss', $array2, $period_from);
$result->execute();
$result->bind_result($app_id, $time_start);
while($result->fetch()){
echo '..results here..';
}
I'm struggling with first one, so could not even check second one - if I can bind at all $array2 to string.
Hope it's clear.