2016-04-17 26 views
2

文字列にしか含まれていない場合は、英語の文字だけが含まれているとstackoverflowに多くの質問があります。私は、文字列が英語の手紙を持っている場合、私がチェックすることができます方法を知っているしたいと思います:文字列に英語の文字があるかどうかを確認する方法

例:

$string="で書くタッチイベント B A(フ"; 

if(??? $string) 
    //this string has some english letters . 
+0

'preg_match()'を実行し、どこでも英語の文字を一致させることができるかどうか確認してください。 – Rizier123

+0

多分 'if(preg_match_all( '/ [A-Za-z] /'、$ string))' – Amous

答えて

4

使用preg_match()

例: -

<?php 
$subject = "abcdef"; 
$pattern = '/^def/'; 
preg_match($pattern, substr($subject,3), $matches, PREG_OFFSET_CAPTURE); 
print_r($matches); 
?> 

WRTの質問、それ -

<?php 
$string = "で書くタッチイベント B A(フ"; 
$pattern = '/[a-zA-Z]/'; 
preg_match($pattern, $string, $matches); 
print_r($matches); 
?> 
関連する問題