some php functions used in WordPress source code

strip_tags("hello <p> world</p>")–> “hello word”

list($a,$b,$c)=$myarray; $a<=$myarray[0],$b<=$myarray[1],$c=$myarray[2]

compact("variablename1","variablename2",...") returns an array whose members are "variablename1"=>$variablename1, "variablename2"=>$variablename2, …. if $variablename is not in the current scope, compact won’t include it.

array_rand($arr) randomly picks up an entry from the array $arr and returns its key.

array_count_values($arr) counts the frequency of values of $arr and return an array with values as the keys and their frequencies as the values.

preg_match_all($pattern,$str,$matches) finds all matches of $pattern in $str, and puts the results to $matches. $matches[0] stores all matches of the pattern. $matches[1] stores all strings that matched the first parenthesized subpattern, $matches[2] stores all strings that matched the second parenthesized subpattern, and so on.

If you like my content, please consider buying me a coffee. Buy me a coffeeBuy me a coffee Thank you for your support!

Leave a Reply