-5

how can I show this image if hop_nr is a number of from the bellow.

if $man->hop_nr == AA44000000 or AA44738483 or AA45665839 or AA45697117 or AA45853322 or AA46593303 or AA46913044 or AA46913252 or AA46913631 or AA47362505 or AA47442114 or AA47452676 or AA47512000 or AA47542321 or AA47564838 or AA47592086, AA48622280 or AA48632711 or AA48644000 or AA48660000 or AA48666000 or AA49732000, AA49742000 or AA49781113 or AA49819308 or AA49831888 or AA49851138 or AA49890383 show <img src="/media/store_logos/tlogo.png”>

Timothy Groote
  • 8,614
  • 26
  • 52
Tobias
  • 25
  • 1

2 Answers2

7

You can search through an array of numbers:

$numbers = ['AA44000000', 'AA44738483', 'AA45665839', 'AA45697117', 'AA45853322', 'AA46593303', 'AA46913044', 'AA46913252', 'AA46913631', 'AA47362505', 'AA47442114', 'AA47452676', 'AA47512000', 'AA47542321', 'AA47564838', 'AA47592086', 'AA48622280', 'AA48632711', 'AA48644000', 'AA48660000', 'AA48666000', 'AA49732000', 'AA49742000', 'AA49781113', 'AA49819308', 'AA49831888', 'AA49851138', 'AA49890383']

if (in_array($man->hop_nr, $numbers)) {
    //show the image
}

Official documentation for in_array function.

jrenk
  • 1,387
  • 3
  • 24
  • 46
2
$arr = array('AA44000000','AA44738483','AA45665839'); // all your values

Use in_array for this like:

// search if value $man->hop exists in $arr
if (in_array($man->hop, $arr))
  {
        //do what you want
  }

Read https://www.w3schools.com/php/func_array_in_array.asp

Kevin
  • 1,232
  • 10
  • 28
Passionate Coder
  • 7,154
  • 2
  • 19
  • 44