jeudi 25 février 2016

get a minus or plus in number

i have some function in PHP i do some collected in SQL and number from a input

and i stack there how its should be.

my code:

        $x = $request->input('usd');
        $roi = $profit / $request->input('usd');
        $cor = $request->input('usd') - $profit;
        $prof = abs($profit);

        $data['roi'] = $roi >= 0 ? '+'. $roi : '-'. $roi;
        $data['cor'] = $cor >= $x ? '+' . $cor : '-' . $cor;
        $data['prof'] = $profit >= $x ? '+' . $prof : '-' . $prof;

$x example = 1000$ but its always do a + in minus numbers and plus in - numbers.



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/24rp0kV
via IFTTT

Aucun commentaire:

Enregistrer un commentaire