php 函数集锦

1、array_intersect_assoc()用于比较两个(或更多个)数组的键名和键值,并返回交集。

<?php
$a1=array("a"=>"red","b"=>"green","c"=>"blue","d"=>"yellow");
$a2=array("a"=>"red","b"=>"green","c"=>"blue");

$result=array_intersect_assoc($a1,$a2);
print_r($result);
?>

运行结果:

Array ( [a] => red [b] => green [c] => blue )

 2、parse_str()把查询字符串解析到变量中。

parse_str(string,array)
string 必需。规定要解析的字符串。
array 可选。规定存储变量的数组的名称。该参数指示变量将被存储到数组中。

 3、preg_replace()执行一个正则表达式的搜索和替换

在subject中搜索pattern, 以replacement进行替换。
preg_replace ( mixed $pattern , mixed $replacement , mixed $subject [, int $limit = -1 [, int &$count ]] )
原文地址:https://www.cnblogs.com/mmady/p/6928592.html