How can Mehrdimensionale Arrays in PHP be filtered to output specific data based on a condition?

To filter Mehrdimensionale Arrays in PHP to output specific data based on a condition, you can use a loop to iterate through the array and check the condition for each element. If the condition is met, you can store that element in a new array or output it directly. This allows you to selectively display or manipulate the data based on your criteria.

// Sample Mehrdimensionale Array
$array = [
    ['name' => 'John', 'age' => 25],
    ['name' => 'Alice', 'age' => 30],
    ['name' => 'Bob', 'age' => 20]
];

// Filter the array to output only elements where age is greater than 25
foreach ($array as $element) {
    if ($element['age'] > 25) {
        echo $element['name'] . ' is ' . $element['age'] . ' years old' . PHP_EOL;
    }
}