2
What is the difference between the functions preg_split
and explode
? When to use one or the other?
I came across this code and I’m trying to understand its workings.
function consulta_header_grid($campos){
$linha = preg_split('/[\n]/', $campos, -1, PREG_SPLIT_NO_EMPTY);
foreach($linha as $linha){
$colunas = explode(" ", $linha);
$header[$colunas[0]] = $colunas[0] . ";" . $colunas[1] . ";" . $colunas[2];
}
return $header;
}
Thank you very much, I help me a lot.
– tadeu miranda