Skip to content
Advertisement

How to handle nulls when doing a sum in php

I have the following data of which I’m trying to sum up the total fare but php keeps throwing this error Warning: A non-numeric value encountered in....

JavaScript

I have tried the above, it adds up the numbers correctly but still keeps throwing the error. What is the correct way of handling this error? I

Advertisement

Answer

You are adding up string values cast them to float

JavaScript
User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement