数组的使用
$dirfile = file( "dir.txt" ); $dirlist = array(); $namelist = array(); foreach($dirfile as $key=>$value){ $wordStr = explode('>',$value);//分割字符串 array_push($dirlist, $wordStr[0]);//添加数据 array_push($namelist, $wordStr[1]); } $dirlistArr = array();//二维数组 $dirlistArr[0] = $dirlist; $dirlistArr[1] = $namelist;
查找
array_search("查找的字符串","内容"); //返回数组索引