mercredi 6 février 2019

How to write an if statement depending on a foreach result?

I'm creating a voucher generating system, i want to generate vouchers depending on the amount paid.

I am able to fetch payment details in my database and put them in an array.

$getpayments = "url/voucherpayments";`enter code here`
$data =[
  'main_attributes' => [
      'id' => $row['id']
  ]
  ];

$result = $api->api_call_get($getpayments. '?' .http_build_query($data));

foreach($api->response as $info) {
    $info['amount'];
    $info['phone_number'];

};

I want to write an if statement that checks, if $info['amount']; is 10, define a new variable $voucher = 10; I will then use this Variable ($voucher) in another function to generate the voucher.

Aucun commentaire:

Enregistrer un commentaire