Within your for
, you are comparing an integer value, $i
, to an array , $count
, and PHP thinks doing this comparison is quite normal and does not complains about this, but if you do well, it does not make sense. You need to compare two integer values and, as the second one should seem to be the size of the array , get that second value with count($count)
:
<?php
$string="array.jpg,teste.pdf,word.docx";
$count=explode(",", $string);
for($i = 0; $i < count($count); $i++){
echo $count[$i];
}
See working at Ideone | Repl.it
Notice that I also changed the operator from <=
to <
, since the indexing of array starts at zero and goes to n-1
, with no value in n
. / p>
But the same result can be obtained with foreach
:
<?php
$string="array.jpg,teste.pdf,word.docx";
$count=explode(",", $string);
foreach($count as $arquivo){
echo $arquivo;
}
See working at Ideone | Repl.it