的每个子阵列我有一个PHP数组格式:如何将数据追加到一个数组
[0] => Array
(
[post_id] => 37
[post_title] => الأَبْجَدِيَّة العَرَبِيَّة
[post_image] =>
[post_status] => 1
)
[1] => Array
(
[post_id] => 36
[post_title] => TEST open for text
[post_image] => post_1463052793.jpeg
[post_status] => 1
)
[2] => Array
(
[post_id] => 35
[post_title] => Hey Sushovan
[post_image] => post_1463038438.jpg
[post_status] => 1
)
现在,我想与附加价值的额外指标。对于这一点,我使用这个代码:
$all_data = $this->master_model->fetch_all_data_order_by($entity, $selectString, $entity.'_publish_date', 'DESC', $limit, $offset = $page);
$data['all_data']=$all_data;
foreach($all_data as $ad => $row)
{
$fetch = '*';
$table = 'chat';
$cond = $table."_to = 'A' AND post_id = '".$row['post_id']."' AND chat_view_status = 0";
$count = $this->master_model->count_data_by_condition($fetch,$table,$cond);
$pushArr = array('chat_count' => $count);
array_push($row,$pushArr);
}
但是,我不能将数据推入原$all_data
。 我该如何做到这一点?
[0] => Array
(
[post_id] => 37
[post_title] => الأَبْجَدِيَّة العَرَبِيَّة
[post_image] =>
[post_status] => 1
[chant_count] => 2
)
通过调用count_data_by_condition()
方法检索聊天计数。
你要添加的chant_count还是要合并/改写? – KiwiJuicer
你可以发布你的数组吗? –
@BikashP。我已经发布了数组结构,bro。 – Saswat