Size dynamic array PHP, POST way, with Jquery

one text

I have a PHP page when I get elements dinamically, into the array "elements[]", using Jquery. So, the user can add N elements, without limit. This data is sent way POST.

send.php:

<script type="text/javascript"> 
   $(document).ready(function() {
        var i = 0;       
        $("#add").click(function() {
            ++i;  
             $('#dynamic_field').append('<tr id="row'+i+'"><td><input style="width: 120px; display: inline;" type="text" name="elements[]" class="form-control name_list" /> </tr>');
        });
        
        $('#submit').click(function() {
            $.ajax({
            url:"pageReceive.php",
            method:"POST",
            data:$('#add').serialize(),
            success:function(data)
            {
                alert(data);
                $('#add')[0].reset();
            }
            });
        });
    });
</script>

Testing, I added 3 elements. If I do:

pageReceive.php

for($i=0; $i<3; $i++) 
{ 
   $elements = $_POST['elements'][$i]; 
   var_dump($elements);
} 

The result for var_dump is:

string(1) "2"

But var_dump shows the data added, only one.

The question is: How can I know, in receivePage.php, HOW MANY elements were sent, without any previous for/foreach to travel around the array ??

Currently, I can read the data passed without problems, but I need to know before HOW MANY elements were sent.

Thanks!

Source