I have a PHP array that I am trying to split into 2 different arrays. I am trying to pull out any values that contain the word \"hidden\". So one array would contain all the v
$myArray = Array('item1', 'item2hidden', 'item3', 'item4', 'item5hidden');
$arr1 = array();
$arr2 = array();
foreach ($myArray as $item) {
if (strpos($item, "hidden") !== false) {
$arr1[] = $item;
} else {
$arr2[] = $item;
}
}
This solution checks if 'hidden' present at current item, if no, move to $arr1
else to $arr2