Format numbers displayed in table

Format numbers displayed in table

leonardharleyleonardharley Posts: 5Questions: 1Answers: 0

Hi - please excuse this really noob question - I'm sure it's very simple but I'm just not getting it through lack of knowledge / experience.

I have an array object being served by a PHP back-end (Laravel 5). In my HTML view I iterate the array to build the table like so...

<table id="tableID">
            <thead>
                <th>Item 1</th>
                 ............
                <th>Item x</th>
            </thead>
            <tbody>
                blade foreach($array_elements as $element)
                       <tr>
                            <td>{{ $element->1 }}</td>
                             ............
                            <td>{{ $element->x }}</td>
                        </tr>
                endforeach
            </tbody>
        </table>

The JS...

$('#tankleveltable').DataTable({
     searching: false,
     paging: false,
     info: false,
     ordering: false })

The data elements in the array are strings and numbers. What I need is for my numbers which are coming through raw (e.g. 100000) to be displayed in the table like so 100000 -> 100,000

I know this is a really really stupid question as formatting like this is just standard stuff but how do I do it? Or should I be pre-formatting the numbers before serving to the view?

Thanks in advance.

Len

This question has an accepted answers - jump to answer

Answers

This discussion has been closed.