Hi! Could we please enable some services and cookies to improve your experience and our website?
Online Sandbox for SQL and PHP: Write, Run, Test, and Share SQL Queries and PHP Code
<?php
global $item;
$item = (object) [
'prices' => [444555333, 444555330, 444555, 444555335, 444555337]
];
getMinPrice($item);
function getMinPrice($item) {
usort($item->prices, function($a, $b){
if ($a == $b) {
return 0;
}
return ($a < $b) ? -1 : 1;
});
$result = formatprice($item->prices[0]);
}
function formatPrice($price) {
var_dump($price);
return preg_replace('/\B(?=(\d{3})+(?!\d))/', ',', $price);
}