详解PHP中mb_strpos的使用
mb_strpos
Description//Performs a multi-byte safe strpos() operation based on number of characters. The first character's position is 0,the second character position is 1,and so on.
// 基于字符数执行一个多字节安全的 strpos() 操作。 第一个字符的位置是 0,第二个字符的位置是 1,以此类推。 Parametershaystack
needle
offset
encoding
Return Values
Example $str = "Hello World! Hello PHP"; $pos = mb_strpos( $str,"Hello",mb_internal_encoding() ); echo $pos . PHP_EOL;//0 $pos = mb_strpos( $str,2,mb_internal_encoding() ); echo $pos . PHP_EOL;//13 function mb_str_replace( $haystack,$search,$replace,$offset = 0,$encoding = 'auto' ) { while ( ( $offset = mb_strpos( $haystack,$offset,$encoding ) ) !== false ) { return $haystack; $replace = mb_str_replace( "hello world !hello world !hello world !hello world !","hello","hi" ); //hi PHP !hi PHP !hi PHP !hi PHP ! //PHP是世界上最好的语言😂😂😂😂😂😂 //代码开发代码 (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |