Time of Update: 2017-11-06
執行個體比較兩個字串:<?phpecho substr_compare("Hello world","Hello world",0);?>定義和用法substr_compare()
Time of Update: 2017-11-03
執行個體計算字串 "Hello World!" 中的單詞數:<?phpecho str_word_count("Hello world!");?>定義和用法str_word_count() Function Compute字串中的單詞數。文法str_word_count(string,return,char)參數描述string必需。規定要檢查的字串。return可選。規定 str_word_count() 函數的傳回值。可能的值:0 -
Time of Update: 2017-11-09
執行個體比較兩個數組的鍵名和索引值(使用使用者自訂函數進行比較),並返回差集:<?phpfunction myfunction_key($a,$b){if ($a===$b){return 0;}return ($a>$b)?1:-1;}function myfunction_value($a,$b){if ($a===$b){return 0;}return ($a>$b)?1:-1;}$a1=array("a"=>"red",&
Time of Update: 2017-11-09
執行個體從數組中移除元素,並用新元素取代它:<?php$a1=array("a"=>"red","b"=>"green","c"=>"blue","d"=>"yellow");$a2=array("a"=>"purple","b"=>&q
Time of Update: 2017-11-03
執行個體填充字串的右側,到 20 個字元的新長度:<?php$str = "Hello World";echo str_pad($str,20,".");?>定義和用法str_pad()
Time of Update: 2017-11-03
執行個體把百分比符號(%)符號替換成一個作為參數進行傳遞的變數:<?php$number = 9;$str = "Beijing";$txt = sprintf("There are %u million bicycles in %s.",$number,$str);echo $txt;?>定義和用法sprintf() 函數把格式化的字串寫入一個變數中。arg1、arg2、++
Time of Update: 2017-11-03
執行個體計算 "Hello" 的 soundex 鍵:<?php$str = "Hello";echo soundex($str);?>定義和用法soundex() Function Compute字串的 soundex 鍵。soundex 鍵是 4 字元長的字母數字字串,表示一個單詞的英文發音。soundex() 函數可用於拼字檢查程式。注釋:soundex() 函數為發音相似的單詞建立相同的鍵。提示: metaphone() 比
Time of Update: 2017-11-08
執行個體返回翻轉順序的數組:<?php$a=array("a"=>"Volvo","b"=>"BMW","c"=>"Toyota");print_r(array_reverse($a));?>定義和用法array_reverse()
Time of Update: 2017-11-02
執行個體計算字串 "Hello" 的 SHA-1 散列:<?php$str = "Hello";echo sha1($str);?>定義和用法sha1() Function Compute字串的 SHA-1 散列。sha1() 函數使用美國 Secure Hash 演算法 1。來自 RFC 3174 的解釋 - 美國 Secure Hash 演算法 1:SHA-1 產生一個名為報文摘要的 160
Time of Update: 2017-11-02
執行個體計算兩個字串的相似性並返回匹配字元的數目:<?phpecho similar_text("Hello World","Hello Peter");?>定義和用法similar_text() Function Compute兩個字串的相似性。該函數也能計算兩個字串的百分比相似性。注釋:levenshtein() 函數比 similar_text() 函數更快。不過,similar_text() 函數通過更少的必需修改次數提供更精確的結果。
Time of Update: 2017-11-02
執行個體把查詢字串解析到變數中:<?phpparse_str("name=Peter&age=43");echo $name."<br>";echo $age;?>定義和用法parse_str() 函數把查詢字串解析到變數中。注釋:如果未設定 array 參數,由該函數設定的變數將覆蓋已存在的同名變數。注釋:php.ini 檔案中的 magic_quotes_gpc 設定影響該函數的輸出。如果已啟用,那麼在
Time of Update: 2017-11-02
執行個體在字串中的新行(\n)之前插入分行符號:<?phpecho nl2br("One line.\nAnother line.");?>上面代碼的瀏覽器輸出如下:One line.Another line.上面代碼的 HTML 輸入如下(查看原始碼):One line.<br />Another line.定義和用法nl2br() 函數在字串中的每個新行(\n)之前插入 HTML 分行符號(<br> 或 <br
Time of Update: 2017-11-08
執行個體返回一個升序排列的數組:<?php$a=array("Dog","Cat","Horse","Bear","Zebra");array_multisort($a);print_r($a);?>定義和用法array_multisort()
Time of Update: 2017-11-02
執行個體計算 "World" 的 metaphone 鍵:<?phpecho metaphone("World");?>定義和用法metaphone() Function Compute字串的 metaphone 鍵。metaphone 鍵代表了字串的英語發音。metaphone() 函數可用於拼字檢查程式。注釋:metaphone() 函數為發音相似的單詞建立相同的鍵。注釋:所產生的 metaphone 鍵長度可變。提示:metaphone(
Time of Update: 2017-11-02
執行個體計算文字檔 "test.txt" 的 MD5 散列:<?php$filename = "test.txt";$md5file = md5_file($filename);echo $md5file;?>上面的代碼將輸出:d41d8cd98f00b204e9800998ecf8427e定義和用法md5_file() Function Compute檔案的 MD5 散列。md5_file() 函數使用 RSA 資料安全,包括 MD5
Time of Update: 2017-11-02
執行個體計算字串 "Hello" 的 MD5 散列:<?php$str = "Hello";echo md5($str);?>定義和用法md5() Function Compute字串的 MD5 散列。md5() 函數使用 RSA 資料安全,包括 MD5 報文摘要演算法。來自 RFC 1321 的解釋 - MD5 報文摘要演算法:MD5 報文摘要演算法將任意長度的資訊作為輸入值,並將其換算成一個 128 位長度的"指紋資訊"
Time of Update: 2017-11-08
執行個體檢查鍵名 "Volvo" 是否存在於數組中:<?php$a=array("Volvo"=>"XC90","BMW"=>"X5");if (array_key_exists("Volvo",$a)){echo "Key exists!";}else{echo "Key does not exist!";}?>
Time of Update: 2017-11-02
執行個體計算兩個字串之間的 Levenshtein 距離:<?phpecho levenshtein("Hello World","ello World");echo "<br>";echo levenshtein("Hello World","ello World",10,20,30);?>定義和用法levenshtein() 函數返回兩個字串之間的
Time of Update: 2017-11-02
執行個體把數組元素組合為一個字串:<?php$arr = array('Hello','World!','Beautiful','Day!');echo implode(" ",$arr);?>定義和用法implode() 函數返回一個由數組元素組合成的字串。注釋:implode() 函數接受兩種參數順序。但是由於曆史原因,explode() 是不行的,您必須保證 separator 參數在
Time of Update: 2017-11-02
執行個體反向顯示希伯來字元,並把新行(\n)轉換為 <br>:<?phpecho hebrevc("á çùåï äúùñâ\ná çùåï äúùñâ");?>定義和用法hebrevc() 函數把希伯來文本從右至左的流轉換為左至右的流。同時,把新行(\n)轉換為 <br>。提示:hebrevc() 和 hebrev() 可以把希伯來邏輯文本(Windows