<?php
$result = [
["Apple iPhone 13 128 Go Minuit", "1 379€00"],
["Apple iPhone 14 128 Go Minuit", "1 379€00"],
["Apple iPhone 14 128 Go Lumière Stellaire", "919€00"],
["Apple iPhone 14 Pro 128 Go Noir Sidéral", "919€00"]
];
foreach ($result as $item) {
$price = $item['1'];
$convert_array = ['$', '€', '£', '¥', '₩', '₹', '₽', '฿', '₺', '₴'];
foreach ($convert_array as $symbol) {
if (strpos($price, $symbol) !== false) {
$price = str_replace($symbol, '.', $price);
$price = preg_replace('/\. /', '', $price, 1);
$price = str_replace(',', '.', $price);
break;
}
}
$price_format = trim($price);
if (substr($price_format, -1) == '.') {
$price_format = substr($price_format, 0, -1);
}
if (is_string($price_format)) {
$price_format = number_format((float)str_replace(' ','',$price_format), 2, '.', ' ');
}
if (is_numeric($price_format)) {
$price_format = $price_format . ' num';
}
print_r($price_format);
echo PHP_EOL;
}
- Output for 8.0.1 - 8.0.30, 8.1.0 - 8.1.33, 8.2.0 - 8.2.29, 8.3.0 - 8.3.25, 8.4.1 - 8.4.12
- 1 379.00
1 379.00
919.00 num
919.00 num
preferences:
84.69 ms | 406 KiB | 5 Q