-1
I made a push
array, however, has an attribute that I should put only when it has some value or greater than zero. Normally the table takes the value it has, but it cannot be zeroed. If it is zeroed the bank table puts the default value 0,000.
This is the array:
array_push($itens,
array(
'id' => $id,
'preco_tabela'=> $preco,
'quantidade'=> $quantidade
)
);
I need him to stay that way when the $valorDesconto is greater than 0.000
array_push($itens,
array(
'id' => $id,
'preco_tabela'=> $preco,
'quantidade'=> $quantidade,
'descontos_do_vendedor' => $valorDesconto
)
);
I tried to use the !Empty, but it didn’t work. Someone can help me?
Remembering that the value $valueDesconce is an array as well.
What’s wrong with leaving the field
'descontos_do_vendedor' => $valorDesconto
blank when there is no value?– Gnomo Escalate
Although your question is about empty arrays, your problem has nothing to do with it.
– Gnomo Escalate
it gives an error when inserting because the attribute cannot be empty since informed that has attribute, in the case of this as optional
– Deamble Lopes
I updated with a possible solution below.
– Gnomo Escalate