-2
I need to somehow verify if there is any element within a given array
and if there is, put a whole string
in a specific place. For example:
I need to check whether
$categoria
is not empty
$categoria = array($values);
And after checking that it is not empty, insert the string below inside
filter
$categoria = " 'Categoria' => array($values) ";
The array
is this and I have to insert these instructions into the filter:
$dados = array (
'fields' => array(
'ImoCodigo',
'Categoria',
'Bairro',
'ValorVenda',
'Dormitorios',
'Vagas',
'FotoDestaque'
),
'filter' => array(
// As strings devem ser inseridas exatamente aqui separadas por vírgula
),
'paginacao' => array(
'pagina' => 1,
'quantidade' => 50
)
);
The end result would look like this:
...
'filter' => array(
'Categoria' => array($values),
'Cidade' => array($cidades),
'ValorVenda' => array($preco)
),
...
$dados['filter'][] = $categoria
, since the category is string. I do this to generate JSON and it works. try there. If it doesn’t work, usearray_push()
. Function Docs: http://php.net/manual/en/function.array-push.php– StillBuggin
Caro @Eduardoalmeida is exactly what I’m using for :)
– Marcos Vinicius
Dear @Eduardoalmeida can assemble a response showing the feat please :)
– Marcos Vinicius