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 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);
}
}
You could use 'prayerType'
$timeless = array();
$ontime = array();
foreach( $myArray as $item ) {
if ( $item['prayerType'] == 1 ) {
$timeless[] = $item;
} else {
$ontime[] = $item;
}
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.