3v4l.org

run code in 300+ PHP versions simultaneously
<?php $second_names = ['Cars', 'Bikes', 'Trucks']; $premiumCatArraySets = [ [ 'primary-category' => 'Automobiles', 'secondary-category' => 'Cars', 'tertiary-category' => 'Fiat Punto' ], [ 'primary-category' => 'Automobiles', 'secondary-category' => 'Cars', 'tertiary-category' => 'BMW' ], [ 'primary-category' => 'Automobiles', 'secondary-category' => 'Bikes', 'tertiary-category' => 'Honda' ], [ 'primary-category' => 'Automobiles', 'secondary-category' => 'Trucks', 'tertiary-category' => 'Iveco' ] , [ 'primary-category' => 'Automobiles', 'secondary-category' => 'Cars', 'tertiary-category' => 'Mercedes' ] , [ 'primary-category' => 'Automobiles', 'secondary-category' => 'Cars', 'tertiary-category' => 'Toyota' ] ]; $output = []; foreach($premiumCatArraySets as $key => $value){ if(in_array($value["secondary-category"],$second_names)){ if(!isset($output[$value["secondary-category"]])){ $output[$value["secondary-category"]] = []; } $output[$value["secondary-category"]][] = $value["tertiary-category"]; } } foreach($output as $key => $value){ echo '<h2>'.$key."</h2>"; echo implode(",",$value)."<br/>"; } print_r($output);
Output for git.master, git.master_jit, rfc.property-hooks
<h2>Cars</h2>Fiat Punto,BMW,Mercedes,Toyota<br/><h2>Bikes</h2>Honda<br/><h2>Trucks</h2>Iveco<br/>Array ( [Cars] => Array ( [0] => Fiat Punto [1] => BMW [2] => Mercedes [3] => Toyota ) [Bikes] => Array ( [0] => Honda ) [Trucks] => Array ( [0] => Iveco ) )

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
130.5 ms | 406 KiB | 5 Q