3v4l.org

run code in 300+ PHP versions simultaneously
<?php // SELECT `link_id`, `link_name`, `alias` FROM `m5cob_mt_links` WHERE `alias` = '' // indexed resultset... $resultset = [ [6, 'Convivio Bar & Restaurant Chester Cheshire UK', ''], [7, 'Slug and Lettuce Chester Cheshire UK', ''], [8, 'Da Rosa Restaurant 1 & Wine Bar Torrevieja Costa Blanca Spain', ''], [9, 'Bar Lounge Chester Cheshire UK', ''], [10, 'Telfords Warehouse Chester Cheshire UK', ''], [11, 'The Botanist Chester Cheshire UK', ''], [12, 'Missoula Chester Cheshire UK', ''], [13, 'Fiesta Havana Chester Cheshire UK', ''], [14, 'El Oceano\'s Hotel Restaurant, Torrenueva, Marbella, Malaga', ''], [15, 'La Plaza Restaurant Riviera del Sol Mijas Costa Malaga Spain', ''] ]; foreach ($resultset as $row) { $purged = preg_replace('~[^a-z ]+~', '', strtolower($row[1])); $split = preg_split('~ +~', $purged, 6, PREG_SPLIT_NO_EMPTY); $new_alias = implode('-', array_slice($split, 0, 5)); echo "{$row[0]}: $new_alias\t\t(from: {$row[1]}\n"; // UPDATE `m5cob_mt_links` SET `alias` = '$new_alias' WHERE `link_id` = $row[0] }
Output for 5.6.0 - 5.6.40, 7.0.0 - 7.0.33, 7.1.0 - 7.1.33, 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.27, 8.2.0 - 8.2.18, 8.3.0 - 8.3.4, 8.3.6
6: convivio-bar-restaurant-chester-cheshire (from: Convivio Bar & Restaurant Chester Cheshire UK 7: slug-and-lettuce-chester-cheshire (from: Slug and Lettuce Chester Cheshire UK 8: da-rosa-restaurant-wine-bar (from: Da Rosa Restaurant 1 & Wine Bar Torrevieja Costa Blanca Spain 9: bar-lounge-chester-cheshire-uk (from: Bar Lounge Chester Cheshire UK 10: telfords-warehouse-chester-cheshire-uk (from: Telfords Warehouse Chester Cheshire UK 11: the-botanist-chester-cheshire-uk (from: The Botanist Chester Cheshire UK 12: missoula-chester-cheshire-uk (from: Missoula Chester Cheshire UK 13: fiesta-havana-chester-cheshire-uk (from: Fiesta Havana Chester Cheshire UK 14: el-oceanos-hotel-restaurant-torrenueva (from: El Oceano's Hotel Restaurant, Torrenueva, Marbella, Malaga 15: la-plaza-restaurant-riviera-del (from: La Plaza Restaurant Riviera del Sol Mijas Costa Malaga Spain
Output for 8.3.5
Warning: PHP Startup: Unable to load dynamic library 'sodium.so' (tried: /usr/lib/php/8.3.5/modules/sodium.so (libsodium.so.23: cannot open shared object file: No such file or directory), /usr/lib/php/8.3.5/modules/sodium.so.so (/usr/lib/php/8.3.5/modules/sodium.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0 6: convivio-bar-restaurant-chester-cheshire (from: Convivio Bar & Restaurant Chester Cheshire UK 7: slug-and-lettuce-chester-cheshire (from: Slug and Lettuce Chester Cheshire UK 8: da-rosa-restaurant-wine-bar (from: Da Rosa Restaurant 1 & Wine Bar Torrevieja Costa Blanca Spain 9: bar-lounge-chester-cheshire-uk (from: Bar Lounge Chester Cheshire UK 10: telfords-warehouse-chester-cheshire-uk (from: Telfords Warehouse Chester Cheshire UK 11: the-botanist-chester-cheshire-uk (from: The Botanist Chester Cheshire UK 12: missoula-chester-cheshire-uk (from: Missoula Chester Cheshire UK 13: fiesta-havana-chester-cheshire-uk (from: Fiesta Havana Chester Cheshire UK 14: el-oceanos-hotel-restaurant-torrenueva (from: El Oceano's Hotel Restaurant, Torrenueva, Marbella, Malaga 15: la-plaza-restaurant-riviera-del (from: La Plaza Restaurant Riviera del Sol Mijas Costa Malaga Spain

preferences:
224.08 ms | 403 KiB | 286 Q