<?php
$iplist = "122.224.251.154|192.168.2.138|192.168.2.12";
echo $_SERVER['REMOTE_ADDR'] . "<br/>";
$arr = explode('|', $iplist); // 将iplist用'|'分割 echo "<br/>";
print_r($arr);
echo "<br/>";
foreach($arr as $key => $ip) // 遍历数组1
{
echo "$key = $ip<br/>";
} echo "<br/>";
reset($arr); // 重置arr数组指针
print_r($arr);
echo "<br/>";
while (list($key, $val) = each($arr)) // 遍历数组2
{
echo "$key = $val<br/>";
} echo "<br/>";
$str = " hello world \n ";
$str = trim($str); // trim()
echo "#$str#<br/>"; echo "<br/>";
$arr = array(1, 2, array('hello', 'world', 33), 66, 'come on');
print_r($arr); // 打印嵌套数组
echo "<br/>"; echo "<br/>";
$arr = array(
'name' => 1,
'nick' => 2,
'arr' => array('hello', 'world', 33),
66,
'come on'
); // 这种方式的数组相当于json/dict格式了
print_r($arr);
echo "<br/>";
?>