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.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire