Home > Mobile >  number_format(): Argument #1 ($num) must be of type float
number_format(): Argument #1 ($num) must be of type float

Time:12-13

When I add this code to my blade. It displays and shows an array.

['2600000']

['4500000']

@foreach($amazings as $product)
    {{ number_format($product->prices->pluck('value')) }}
@endforeach

CodePudding user response:

Pluck will still return a collection. You'd need to iterate through it, either with another foreach loop, or such as through map, etc:

@foreach($amazings as $product)
    @foreach($product->prices->pluck('value')->all() as $val)
        {{ number_format($val) }}
    @endforeach
@endforeach

CodePudding user response:

make the value $num float then pass that to that function. Use floatval($num) See documentation https://www.php.net/manual/en/function.floatval.php

  • Related