PHPize Online / SQLize Online  /  SQLtest Online

A A A
Share      Blog   Popular
Copy Format Clear
Copy Clear
Copy Format Clear
<?php $lines = [ '4e84||some text||category A', 'f17b||words words||category B', 'f7ac||some more text here||category B', '8683||text text||category C', 'b010||more text||category A', 'fcc4||more text||category B', 'we47||more text||category C', '08ml||more text||category A' ]; $split_lines = []; // first - split lines and put them into array // using third parameter as key foreach ($lines as $line) { $split_lines[] = explode('||', $line); } // sort array by function usort($split_lines, fn($a,$b)=>$a[2]<=>$b[2]); // show array as table foreach ($split_lines as $line) { echo '<tr>'; echo '<td>'.$line[0].'</td>'; echo '<td>'.$line[1].'</td>'; echo '<td>'.$line[2].'</td>'; echo '</tr>' . PHP_EOL; } ?>
Show:  
Copy Clear