3v4l.org

run code in 300+ PHP versions simultaneously
<?php $array_list = 'a:5:{i:0;a:3:{s:2:"id";s:3:"191";s:4:"name";s:3:"Ali";s:5:"range";s:5:"today";}i:1;a:3:{s:2:"id";s:3:"190";s:4:"name";s:4:"John";s:5:"range";s:5:"today";}i:2;a:3:{s:2:"id";s:3:"189";s:4:"name";s:5:"peter";s:5:"range";s:12:"in last week";}i:3;a:3:{s:2:"id";s:3:"180";s:4:"name";s:3:"Ali";s:5:"range";s:12:"in last week";}i:4;a:3:{s:2:"id";s:3:"170";s:4:"name";s:4:"Jack";s:5:"range";s:12:"in last week";}}'; $array_list = unserialize($array_list); $new_list = array(); foreach( $array_list as $list ) $new_list[$list['range']][] = $list; ?> <div id="notification_box"> <?php foreach( $new_list as $item_name => $items ): ?> <div class= "cases"> <div class="title"><?php echo $item_name ?></div> <?php if( $items && is_array( $items ) ) { ?> <table> <?php foreach( $items as $item ): ?> <tr> <td><?php echo $item['id'] ?></td> <td><?php echo $item['name'] ?></td> </tr> <?php endforeach; ?> </table> <?php } ?> </div> <?php endforeach; ?> </div>
Output for 5.5.0 - 5.5.36, 5.6.0 - 5.6.28, 7.0.0 - 7.0.20, 7.1.0 - 7.1.25, 7.2.0 - 7.2.33, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.19, 8.3.0 - 8.3.7
<div id="notification_box"> <div class= "cases"> <div class="title">today</div> <table> <tr> <td>191</td> <td>Ali</td> </tr> <tr> <td>190</td> <td>John</td> </tr> </table> </div> <div class= "cases"> <div class="title">in last week</div> <table> <tr> <td>189</td> <td>peter</td> </tr> <tr> <td>180</td> <td>Ali</td> </tr> <tr> <td>170</td> <td>Jack</td> </tr> </table> </div> </div>

preferences:
234.87 ms | 406 KiB | 232 Q