的每個子陣列我有一個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