[PHP] Новичкам: задаем вопросы

Discussion in 'PHP' started by Kaimi, 7 May 2015.

  1. winstrool

    winstrool ~~*MasterBlind*~~

    Joined:
    6 Mar 2007
    Messages:
    1,417
    Likes Received:
    815
    Reputations:
    848
    echo $m."<br>";
     
    _________________________
    people2people likes this.
  2. people2people

    people2people Banned

    Joined:
    1 Dec 2019
    Messages:
    167
    Likes Received:
    64
    Reputations:
    0
    Code:
    foreach($mas as $m) {
    
         if (strpos($m,"showthread")) {
          echo $m;
         }
    }
    выдает:
     
  3. ckpunmkug

    ckpunmkug Member

    Joined:
    20 Mar 2017
    Messages:
    58
    Likes Received:
    52
    Reputations:
    3
    Потому что strpos возвращает или позицию в int или false в boolean.
    Правильно так:
    Code:
    foreach($mas as $m) {
          if (strpos($m,"showthread") !== false) {
             echo $m, "<br>";
          }
    }
     
    Skofield, ex0dus and people2people like this.
  4. Skofield

    Skofield Elder - Старейшина

    Joined:
    27 Aug 2008
    Messages:
    951
    Likes Received:
    316
    Reputations:
    52
    В языковой конструкции 'echo' необязательно использовать конкатенацию(точку). Вполне правильным также будет передать список аргументов через запятую.
     
Loading...