| 内容 | <?php
 //php获取最后一个特定字符位置,函数如下,
 /*
 * forasp 要查找的字符串
 * cn是要查找的特定字符
 */
 function get_last_code_pos($forasp,$cn){
 $forasparr= explode($cn,$forasp);
 $lastforaspcn = $forasparr[count($forasparr)-1];//获取最后的一个分组
 return strlen($forasp)-strlen($lastforaspcn)-1;
 }
 $forasp = "这里是要查询的字符串,www,www,forasp.cn,www网站制作学习网原创,php获取特定字符位置forasp.cn";//3w.foa($)sp.cn
 $cn ="www";
 echo get_last_code_pos($forasp,$cn);
 //结果51,在utf8下中文占3个字符位置
 $forasp = "abcdefgabcdefasp.cn";
 $cn ="c";//获取最后一个字符c的位置
 echo get_last_code_pos($forasp,$cn);
 //结果17
 |