扫码关注官方订阅号
opencart 3
another telephone
我在供应商商店表单中添加了自定义字段“另一部电话”。 它接受字母、数字和符号。
问题:我想验证我的字段中的电话号码是否有效。
附图:文本字段 > 另一个电话
也许我没有正确理解您的问题,但如果您需要将另一部以字母为字母的手机更改为按字母/数字模式的数字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)你可以试试这个:
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));
微信扫码关注PHP中文网服务号
QQ扫码加入技术交流群
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
PHP学习
技术支持
返回顶部
也许我没有正确理解您的问题,但如果您需要将另一部以字母为字母的手机更改为按字母/数字模式的数字
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));