3v4l.org

run code in 300+ PHP versions simultaneously
<?php $upsells = ['Наименование товара №1_~-250$_~-99$', 'Наименование товара №2_~-699$_~-399$', 'Наименование товара №3_~-299$_~-149$',]; $orderDetails = ['Наименование', 'Старая цена', 'Новая цена']; $text = ''; foreach ($upsells as $upsell) { $productInformation = explode('_~-', $upsell); for ($i = 0; $i < count($productInformation); $i++) { $text .= '<b>'.$orderDetails[$i].':</b> '.$productInformation[$i].'<br />'; } } echo $text;

preferences:
47.3 ms | 1589 KiB | 5 Q