0
I have the following code:
  $urls = file_get_contents('https://www.google.com/#q=teste'); // teste é a palavra que vai pesquisar no google
    preg_match_all('/\b(?:(?:https?|http):\/\/|www\.)[-a-z]*.com.br/i', $urls, $content); // filtra apenas as urls .com.br da pagina
    $i = 10; // inicia do 10
    while ( $i <= 50 ) { // o while vai entrar nas paginas da paginação, 50 quer dizer até a pagina 5 da paginação, pois cada pagina exibe 10 resultados
    $i+= 10;
    $urls2 = file_get_contents('https://www.google.com/#q=teste&start=".$i."'); // start é onde vai iniciar na proxima pagina (paginação dos resultados da pesquisa)
    preg_match_all('/\b(?:(?:https?|http):\/\/|www\.)[-a-z]*.com/i', $urls2, $contentLoop);
    $totalArray = array_merge($content,$contentLoop);
    }
    print_r($totalArray);
Inside while preg_match_all on each turn creates a different array since file_get_contents tbm is changed according to pagination (because of $i in url).
How do I enter the $totalArray variable to have a single array with all arrays captured during the loop and access the $totalArray variable outside the loop?
I appreciate help
please edit your question by putting the
arraythat is being generated at this time, and a model of what you expect.– Kenny Rafael