jeudi 20 septembre 2018

Calculation using array values in PHP

If I have a multidimensional array, how can I make it so that certain groups in the array (ex: 'wages', 'hrs' ) will be plugged into a certain formula to become $x, so that it can go through the ifelse statement below?

I'm calculating monthly salary with this general function: ($employees[0]['wage']) * ($employees[0]['hrs']) * 4 However, I want to know how to format the first bracket (key?) $employees[ _ ] , so that every value of the array under the 'hrs' and 'wage' values goes through to calculate what $x would be for EVERY employee in the array (there are 9). I'm assuming I would create a loop, but how would I fill in the bracket to make that happen?

<?php

   $x = __

    if ( $x >= 3000 ) { 
      echo "High paying"; 
     } elseif ( 2000 =< x =< 2999 ) {
        echo "Good paying";
     } else {
      echo "Low paying"; 
     } 
?>  

Aucun commentaire:

Enregistrer un commentaire