Heim  >  Fragen und Antworten  >  Hauptteil

Öffnen Sie die Telefonnummer im Warenkorb mithilfe der PHP-Verifizierung

opencart 3

<div class="form-group ">
   <label class="col-sm-2 control-label" for="input-name"> another telephone</label>
   <div class="col-sm-10">
      <input type="text" name="another_telephone" value="{{another_telephone}}" class="form-control" placeholder="another telephone">
   </div>
</div>

Ich habe ein benutzerdefiniertes Feld „Anderes Telefon“ zu meinem Händler-Shop-Formular hinzugefügt. Es akzeptiert Buchstaben, Zahlen und Symbole.

Frage: Ich möchte überprüfen, ob die Telefonnummer in meinem Feld gültig ist.

Bild im Anhang: Textfeld > Ein weiterer Anruf

P粉269847997P粉269847997175 Tage vor291

Antworte allen(1)Ich werde antworten

  • P粉187677012

    P粉1876770122024-04-01 00:04:21

    也许我没有正确理解您的问题,但如果您需要将另一部以字母为字母的手机更改为按字母/数字模式的数字2(A,B,C) 3(D,E) ,F) 4(G,H,I) 5(J,K,L) 6(M,N,0) 7(P,Q,R,S) 8(T,U,V) 9(W,X) ,Y,Z)你可以试试这个:

    $another_phone = 'holidays1';
    $alias_array = array(
        '0' => ['0'],
        '1' => ['1'],
        '2' => ['A','B','C'],
        '3' => ['D','E','F'],
        '4' => ['G','H','I'],
        '5' => ['J','K','L'],
        '6' => ['M','N','O'],
        '7' => ['P','Q','R','S'],
        '8' => ['T','U','V'],
        '9' => ['W','X','Y','Z']);
        
    $phone_in_letters = strtoupper($another_phone);
    //creating an array
    $phone_in_letters_array = str_split($phone_in_letters );
    
    $phone_array = [];
    foreach($phone_in_letters_array as $val) {
        foreach ($alias_array as $key => $letters) {
            if (in_array($val, $letters)) {
                $phone_array[] = $key;
            }
        }
    }
    
    print_r(implode($phone_array));

    Antwort
    0
  • StornierenAntwort