lundi 22 août 2016

Get first unique value on loop and make others zero with if statement

How can i get the first unique value on a foreach loop and make the others which is not unique to zero using if else statement?

I have this working loop that would result to :

266,111.69
266,111.69
150,000.00
150,000.00
150,000.00

This would be the result i would like to happened :

266,111.69
0
150,000.00
0
0

The code would be something like this :

$query = $this->db->query("SELECT * FROM " .tbl_loan_master." WHERE id = "2" AND deleted = 0");
$loans_debit = $query->row()->loan;


if (** $loans_debit is unique**){
  //echo $loans_debit;
}else{
  //echo 0;
}

Aucun commentaire:

Enregistrer un commentaire