-1
I have a query to my database that returns to me an array each database row is an array,
$qr = DBRead('sales', "WHERE status = 1");
foreach ($qr as $position => $linha){
$vendas = $linha['cod_produto'];
var_dump($vendas);
}
This I printed for the sequinte array
array (size=25)
'venda' => string '96' (length=2)
'cod_produto' => string '1; 2; 8' (length=7)
array (size=25)
'venda' => string '98' (length=2)
'cod_produto' => string '; 1; 2; 8' (length=9)
And so on, the more I register the more arrays.
My question is I want to get the key cod_produto
and selects its value and put in a single string with all these values concatenated someone has an idea of how to do this with php?
Use the Join or implode function. It is simpler and more elegant. function Join: https://www.php.net/manual/en/function.join.php implode function: https://www.php.net/manual/en/function.implode.php
– Hugo da Silva da Silva