php count the number of strings after exploded

前端 未结 5 1071

Here is my code

$key) {
$i >0;
    echo $i.\' \'.$key .         


        
5条回答
  •  一向
    一向 (楼主)
    2021-01-04 19:07

    $key) {
    
        echo $i.' '.$key .'
    '; } ?>

    Try using:

    echo count($tags); // Output of 6
    

    Arrays start with a key of 0, not one. So when using anything else apart from count, you will constantly get 1 less than your expected (unless you modify the array prior to counting)

提交回复
热议问题