I have an array like this:
$where = array(
'product_id' => $product_id,
'item_id' => $item_id
);
I want开发者_StackOverflow社区 to add to this array, based on a condition, so I could do
if($condition){
$where = array()
}else{
$where = array()
}
And repeat the original contents twice, but ideally, I'd like to do like an array_push(array('id' => $id), $where);
Thanks!
you may add something to your array in the following way:
$where['mykey'] ='myvalue';
Simply add it to your array by specifying the index and the value.
if($condition){
$where['id'] = $id;
}else{
$where['other'] = $other;
}
精彩评论