Get string size inside the array with PHP

1

I have the following problem, in the program below, I get the forms of a website, but I have to specify the exact size of the line that has the form (96), would have the possibility to pick up this number without having to specify manually .

<?php
         $url = file_get_contents('site.com');
         if(!$url) {
           trigger_error('Não foi possível ler a url', E_USER_NOTICE);
         }

         $var1 = explode("<form", $url);
         $string = array();

         // Pega o formulário do arquivo HTML.
         for($i = 0; $i < 96; $i++) {
            $string[0][$i] = $var1[1][$i];
         }

?>

I tried to use foreach, but it does not return the right number.

$i = 0;
foreach($var1 as $valor => $detalhes) {
    foreach($detalhes as $detalhes => $saida) {
        $i++;       
     }
}

Thank you!

    
asked by anonymous 25.07.2018 / 00:09

1 answer

1

In your case, it is not the size of the array, but the index of the array you are selecting.

Because the [1] index of the $var1 array is a string, you can count its size with the

25.07.2018 / 02:26