在php中获取数组索引

时间:2015-12-02 06:05:19

标签: php arrays

面临以下问题,PLZ需要解决方案。 请看一下附加图片 此致

enter image description here

3 个答案:

答案 0 :(得分:1)

使用以下代码

$file = fopen("test.txt","r");
$array=array();
while(! feof($file))
  {
    $line       =   fgets($file);
    $arrayChunk = explode("$", $line);
    $array[]    =   $arrayChunk;
  }
fclose($file);
print "<pre>";
print_r($array);

答案 1 :(得分:0)

试试这个

$text = text from file;
$arr = explode("\n",$text);
$final = array();
foreach($arr as $array){
    $final = explode('$SPL$',$array);
}
print_r($final);

答案 2 :(得分:0)

$file = fopen("test.txt","r");
$array=array();
while(! feof($file))
  {
    $file_content = fgets($file);
    $explodedData = explode("$SPL$", $file_content);
    $requiredData[] = $explodedData;
  }
fclose($file);
print "<pre>";
print_r($requiredData);