0
我有陣列$commentArray
從文件中讀取數據,並有像不能copmare串PHP
some data1
some data2
...
--------------- (it's like a break point)
some data
some data
...
---------------
...
所以我在這裏做一些動作我陣列上
for ($i = 0; $i < count($commentArray); $i++)
{
$arrayElem .= $commentArray[$i];
echo($arrayElem);
echo("<br>");
$arrayElem = "";
if($commentArray[$i] == "---------------")
{
/*
$commentArraySorted[$iterator] = $arrayElem;
$arrayElem = "";
$iterator++;
$i++;
*/
echo("STOP<br>");
}
}
但元素問題是,編譯器看不到串---------------
,因爲代碼塊
if($commentArray[$i] == "---------------")
{
/*
$commentArraySorted[$iterator] = $arrayElem;
$arrayElem = "";
$iterator++;
$i++;
*/
echo("STOP<br>");
}
不要」 t工作,但是當我回應數組元素時,元素---------------
也在呼應。
如何從文件中填充$ commentArray? – splash58
'$ commentArray = file(「recordsComment.txt」);' –
添加第二個參數 - 'FILE_IGNORE_NEW_LINES' – splash58