标题 | php获取某个字符字母最后位置 |
范文 | <?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); |
随便看 |
|
在线学习网范文大全提供好词好句、学习总结、工作总结、演讲稿等写作素材及范文模板,是学习及工作的有利工具。