There is a form where the user chooses which list to show (mail, email, everything). The query has already written a condition ( WHERE from = '1' or WHERE from = '0' or without condition) There is a multidimensional array, it contains the [from] key, whose values โ€‹โ€‹can be 0 or 1 . on which the array is created. I deduce

 if ($data[0]['from'] == '1') { echo "ั‚ะตะบัั‚"; } else { echo "ะดั€ัƒะณะพะน ั‚ะตะบัั‚"; } 

And how to bring everything together, when in the key [from] there are both 0 and 1 ?

Here is part of the array

 Array ( [0] => Array ( [id] => 8 [from] => 0 [data_num] => 8 [input_date] => 2017-07-04 [description] => fgfgfg ) [1] => Array ( [id] => 7 [from] => 1 [data_num] => 7 [input_date] => 2017-07-03 [description] => asd ) ) 
  • one
    You do not see the contradiction? How can there be both 0 and 1 at the same time? - Gino Pane
  • you need to write another condition elseif but I donโ€™t know how. - Jabbar Guliyev

3 answers 3

if I understand correctly, then there is simply an array in which under the "from" key lies the value 0 or 1, depending on the value, you need to output something, but there may be a situation that there is "01" or "10". if so then:

 if ($data[0]['from'] === '1') { echo "ั‚ะตะบัั‚"; }elseif ($data[0]['from'] === '0') { echo "ะดั€ัƒะณะพะน ั‚ะตะบัั‚"; }else { echo "ั‚ั€ะตั‚ะธะน ั‚ะตะบัั‚"; } 

    As far as I understand, you want to check this type:

     if (in_array($data[0]['from'], [1, 2])) { echo "ั‚ะตะบัั‚"; } else { echo "ะดั€ัƒะณะพะน ั‚ะตะบัั‚"; } 

    or

     if ($data[0]['from'] == 1 || $data[0]['from'] == 2) { echo "ั‚ะตะบัั‚"; } else { echo "ะดั€ัƒะณะพะน ั‚ะตะบัั‚"; } 

    or

     switch ($data[0]['from']) { case 1: case 2: echo "ั‚ะตะบัั‚"; break; default: echo "ะดั€ัƒะณะพะน ั‚ะตะบัั‚"; break; } 

    Everywhere the result will be the same, choose whatever implementation you like best.

    • the same multidimensional array $ data [0] ['from'] can be = 0, and $ data [1] ['from'] = 1. I need to combine them, as it were - Jabbar Guliyev
    • Show the full code then that in $ data and how you work with it - Yaroslav Molchan
    • Corrected a question. Added part of the array. - Jabbar Guliyev

    Probably like this:

     if ($data[0]['from'] == 0 && $data[1]['from'] == 1) { echo "ั‚ะตะบัั‚"; } else { echo "ะดั€ัƒะณะพะน ั‚ะตะบัั‚"; } 
    • I could use it if I checked different keys - Jabbar Guliyev