String Functions
String 長度:<?php
echo strlen("Hello world!");
?>結果: 12
字數:
<?php
echo str_word_count("Hello world!");
?>結果: 2
反轉:
<?php
echo strrev("Hello world!");
?>結果: !dlrow olleH
Search for a text within a string:
<?php
echo strpos("Hello world!", "world");
?>結果: 6
Tip: The first character position in a string is 0 (not 1).
取代:
<?php
echo str_replace("world", "Dolly", "Hello world!");
?>結果: Hello Dolly!
頁:
[1]