PHP String 简单操作总结

Categories: PHP; Tagged with: ; @ August 28th, 2010 11:23

1. String 长度: strlen($this->notifyEmailTo)

2. Trim: trim($str); // 清除\0, \t, \n等字符

3. Split: explode(",", $str); // 以","隔开的string组成的数组

4. IndexOf:  strrpos ( string $haystack , string $needle [, int $offset = 0 ] )

5. Replace: str_replace("{ID}", $this->id, "ServerID: {ID}");

补充:

indexOf:  $indexOfAt = strrpos($mailAdd, "@");

SubString: $userName = substr($mailAdd, 0, $indexOfAt);

<->



// Proudly powered by Apache, PHP, MySQL, WordPress, Bootstrap, etc,.