Remove square brackets from an array

Asked

Viewed 724 times

-2

You would need to remove the brackets from a print of the results of an array within a While. Follow code:

<?php

$termo = $_GET['termo'];

include "conn.php";
//Consulta busca informações para montar auto-complete 
$sql = "SELECT serie_nome, serie_cod FROM serie WHERE serie_nome LIKE '%$termo%'";
      //$_REQUEST['term']
$res = mysql_query($sql);

while($linha = mysql_fetch_array($res))
{

    $dados[] = array(utf8_encode($linha['serie_nome']));
}

//Envia dados via Json


$dad = json_encode($dados);
echo $dad;

?>
  • 1

    What would be "remove the clasps from a print"?

  • 1
  • Well, I opened this topic because the print of the result brought "[[resultado1], [resultado2]]". But now I solved my problem which was to add the 'label' in the array that the autocomplete recognized the search. Thank you very much for the tip not to use the mysql function but I am developing it for testing and then I will migrate to mysqli and Pdo.

1 answer

-2

I was able to solve my problem by adding the label in the array to make the autocomplete recognize.

$dados[] = array('label' => utf8_encode($linha['serie_nome']));

Browser other questions tagged

You are not signed in. Login or sign up in order to post.