3v4l.org

run code in 300+ PHP versions simultaneously
<?php $usr = (object)[ 'interests' => 'Cats,Dogs,Monkeys,Praying Mantises,Octopuses,Arowanas,Sloths,Tasmanian Tigers' ]; $showMax = 3; printf( 'Interested in: %s', implode( ', ', array_map( fn($v) => sprintf( '<span>%s</span>%s', strtok($v, ','), ($more = substr_count($v, ',')) ? " (+$more)" : '' ), explode(',', $usr->interests, $showMax) ) ) );

preferences:
31.66 ms | 410 KiB | 5 Q