To Be Continued。。。
sprintf ( string $format [, mixed $args [, mixed $... ]] )
例子
1 2 3 4
| <?php $format = 'The %2$s contains %1$d monkeys'; echo sprintf($format, $num, $location); ?>
|
chr — 返回指定的字符
string chr ( int $ascii )
返回相对应于 ascii 所指定的单个字符。
此函数与 ord() 是互补的。
例子
1 2 3 4 5
| $str = "The string ends in escape: "; $str .= chr(27);
$str = sprintf("The string ends in escape: %c", 27); ?>
|
natsort — 用“自然排序”算法对数组排序
bool natsort (array &$array)
本函数实现了一个和人们通常对字母数字字符串进行排序的方法一样的排序算法并保持原有键/值的关联,这被称为“自然排序”。本算法和通常的计算机字符串排序算法(用于 sort())的区别见下面示例。
simplexml_load_string
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
| function arrayToXml($arr) { $xml = "<xml>"; foreach ($arr as $key=>$val) { if (is_numeric($val)){ $xml.="<".$key.">".$val."</".$key.">"; }else{ $xml.="<".$key."><![CDATA[".$val."]]></".$key.">"; } } $xml.="</xml>"; return $xml; }
function xmlToArray($xml) { libxml_disable_entity_loader(true); $values = json_decode(json_encode(simplexml_load_string($xml, 'SimpleXMLElement', LIBXML_NOCDATA)), true); return $values; }
|
curl
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44
|
public function curlByGet() { $url = "http://www.baidu.com";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_HEADER, false);
$output = curl_exec($ch);
curl_close($ch);
print_r($output); }
public function curlByPost() { $url = "http://www.baidu.com"; $post_data = array ("username" => "小明","password" => "12345");
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data);
$output = curl_exec($ch); curl_close($ch);
print_r($output); }
|
希望这篇文章能给你带来知识和乐趣,喜欢博主的文章可以加博主好友哦
有好的文章也可以向博主投稿哦