How to convert a negative number to a positive number with PHP?

Member

katharina

by katharina , in category: PHP , a month ago

How to convert a negative number to a positive number with PHP?

Facebook Twitter LinkedIn Telegram Whatsapp

1 answer

by beatrice.lesch , a month ago

@katharina You can simply convert it to positive using abs function in PHP, here is example:


1
2
3
4
5
6
<?php

$number = -555;

// 555
echo abs($number);