Determining if string ends with another string 
如何确定一个字符串,if the appears at the end of the other字符串。如果他们给我真实的标准打印超时和虚假的if they will help strpos不要。我?P></
| 12
 3
 4
 
 |     Sample Input
 S1:"staff"
 S2:"FF"
 | 
如何使所有的运行这个函数,P></
| 12
 3
 
 |   function matching_ends($s1,$s2){
 }
 | 
		
		
- 一种选择是使用一种体面的语言,在字符串上使用.endswith()方法。;)
 
	 
| 12
 3
 4
 5
 6
 7
 8
 9
 10
 
 | <?php
$s1="testing";
$s2="ing";
echo matching_ends($s1, $s2);
function  matching_ends($s1,$s2){
    return substr($s1, -strlen($s2)) == $s2  ?"true" :"false";
}
?> | 
演示
你可以用这个
| 12
 3
 4
 5
 6
 7
 
 | if( substr($s1, strlen($s1)-1) === substr($s2, strlen($s2)-1))
{
     // Do something when character at the last matches
}
else{
     // Do something when doesn't match
} | 
		
		
- @汉基·潘基有一个更好的答案。我的代码只用于匹配最后一个字符。我答错了问题。:)
- 那为什么不删除帖子;)
- 你也可以直接用-1代替strlen。