i have a array and i want to split it on based on type
and i have this example
$timeless=array();
$ontime=array();
foreach($myArray as $item) {
if (preg_match("/hidden$/i", $item)) {
array_push($timeless, $item);
} else {
array_push($ontime, $item);
}
i have an array which have 20 record and every records contained a key prayerType
which is 0
OR 1
.
You could use 'prayerType'
$timeless = array();
$ontime = array();
foreach( $myArray as $item ) {
if ( $item['prayerType'] == 1 ) {
$timeless[] = $item;
} else {
$ontime[] = $item;
}
}
you can achieve it by checking its value
$timeless=array();
$ontime=array();
foreach($myArray as $item) {
if ($item['prayerType'] == 0) {
array_push($timeless, $item);
}
else{
array_push($ontime, $item);
}
}