3v4l.org

run code in 300+ PHP versions simultaneously
<?php //retrieved from database $kategorier = [ ['Kategori' => 'Burger'], ['Kategori' => 'Pizza'], ['Kategori' => 'Pizza2'], ['Kategori' => 'Pizza3'], ['Kategori' => 'Chinaboks'], ['Kategori' => 'Artiskok'], ['Kategori' => 'Durum'], ['Kategori' => 'Asiatisk'], ['Kategori' => 'Asiatisk2'], ['Kategori' => 'Asiatisk20'], ['Kategori' => 'Asiatisk3'], ]; if ($kategorier) { $kategorier = array_column($kategorier, 'Kategori'); //sort the resulting array as a human would natsort($kategorier); } $previousLetter = null; var_dump($kategorier); #debug code - remove ?> <dl> <?php foreach ($kategorier as $kategori) { $currentLetter = strtoupper($kategori[0]); if ($previousLetter !== $currentLetter) { ?> <dt><h2><?php echo $currentLetter; ?></h2></dt> <?php } ?> <dd><?php echo $kategori; ?></dd> <?php $previousLetter = $currentLetter; } ?> <dl>
Output for git.master, git.master_jit, rfc.property-hooks
array(11) { [5]=> string(8) "Artiskok" [7]=> string(8) "Asiatisk" [8]=> string(9) "Asiatisk2" [10]=> string(9) "Asiatisk3" [9]=> string(10) "Asiatisk20" [0]=> string(6) "Burger" [4]=> string(9) "Chinaboks" [6]=> string(5) "Durum" [1]=> string(5) "Pizza" [2]=> string(6) "Pizza2" [3]=> string(6) "Pizza3" } <dl> <dt><h2>A</h2></dt> <dd>Artiskok</dd> <dd>Asiatisk</dd> <dd>Asiatisk2</dd> <dd>Asiatisk3</dd> <dd>Asiatisk20</dd> <dt><h2>B</h2></dt> <dd>Burger</dd> <dt><h2>C</h2></dt> <dd>Chinaboks</dd> <dt><h2>D</h2></dt> <dd>Durum</dd> <dt><h2>P</h2></dt> <dd>Pizza</dd> <dd>Pizza2</dd> <dd>Pizza3</dd> <dl>

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:
40.37 ms | 407 KiB | 5 Q