我检查了变量是否是一个数组。 我可以通过$array[n]
返回数组中的所需元素;
所以这一切都很好。
但在下面的代码中,如果我去count($array)
,我不会收到返回的元素数量。 sizeof($array)
也不会做这项工作。
//converting string $messages to array:
$messagesArr = explode("<hr/>", $messages);
if (is_array($messagesArr)){print("<p style='color:red'>Array OK<p>");}
else {print("<p style='color:red'>Array not OK<p>");}
$secondElement = $messagesArr[1];
print("<p style='color:red'>second element is: $tweedeElem<p>");
// This one actually outputs the desired second element of the array
$amountMess = count($messagesArr);
print("<p style='color:red'>the amount of messages is: $amountMess<p>");
你在说“$ berichtenArr”吗?如果是,它在哪里定义? – Donovan 2011-03-28 12:34:21
'$ berichtenArr'在哪里设置? – 2011-03-28 12:34:26