I have an array that looks like the below:
staff : staff,company
managers : managers,staff,company
executives : executives,staff,company
customers : customers,company
loyalty members : loyalty members,customers,company
non loyalty : non loyalty,customers,company
The array is made with the following command:
array_push($group_array, "$group : $area");
This array is created from the output of a command and i would like to remove the values staff and customers because for my purposes they are basically parents so i dont want them in my array.
I have been trying to find a way to essentially do this (not my actual php cod)e:
if array_value contains ",group," then remove it
To try and do this i have been trying to use strpos but i cant figure out how to compare the separate areas of my array values. This has only removed all items from my array:
if (strpos($area, ",$group,") !== false) {
$group_array = array_diff($group_array, group_array(",$group,"));
}
Additionally my array will not always match exactly the above but it will always follow the same layout e.g. group : group,parent,parent
I am using php in a html page, if i run this at the bottom of my page:
foreach($group_array as $items ){
echo "$items <br>";
}
My output is blank. I guess because my if is matching everything?
Expected (hoped for ) array would look like this but it is not as simple as remove item 0 and 3 because the array may change:
managers : managers,staff,company
executives : executives,staff,company
loyalty members : loyalty members,customers,company
non loyalty : non loyalty,customers,company
I know i have not worded this well and im expecting a torrent of abuse and downvotes but im trying my best to explain my task and goal.
print_rof your input and expected output php array.