在PHP中获取数组索引[关闭]
问题描述:
Following issue is facing, plz need solution. Please have a look of attach image Regards
以下问题正面临,PLZ需要解决方案。 请看一下附加图像 Regards p> \ n
p>
div>
答
use following code
$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);
答
Try like this
$text = text from file;
$arr = explode("
",$text);
$final = array();
foreach($arr as $array){
$final = explode('$SPL$',$array);
}
print_r($final);
答
$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);