I have an multidimensional array that follows certain pattern but 'x' element is always different?
This is a pattern:
$category['children'][x]['alias']
How to bypass 'x' and get that values?
You can also extract all of the alias columns if that is the only one you are concerned with:
$aliases = array_column($category['children'], 'alias');
If you just want the first one:
$alias = reset($category['children'])['alias'];
$children = $category['children'];
$x = array_pop($children);
$theValue = $children['alias'];
This assumes a few things, you have not provided in your question.
You can get all keys of an array using array_keys
$current = array_keys($category['children']);
$value = $category["children"][$current[0]]["alias"];
This code will get the value of index alias in the first item in the sub array "children".
foreach($category['children'] as $x) { foreach($x as $alias) { //code here using $alias; }}? Loops through eachxto get its values? Not sure the full context or usage