第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問(wèn)題,去搜搜看,總會(huì)有你想問(wèn)的

數(shù)組推送到在php中給出空值的鍵

數(shù)組推送到在php中給出空值的鍵

PHP
呼喚遠(yuǎn)方 2022-07-16 18:22:50
所以我從 json 中獲取一些輸入,即用戶 ID。然后我試圖找到它的朋友和他們的博客以及它各自的評(píng)論。顯然,評(píng)論將不止一個(gè)。因此,每當(dāng)我將這些評(píng)論推送到數(shù)組中的一個(gè)鍵時(shí),我都會(huì)在我的 api 響應(yīng)中得到空值。我嘗試使用簡(jiǎn)單的 $name['comments'] = $res. 但由于會(huì)有多個(gè)評(píng)論,因此它會(huì)用舊評(píng)論替換新評(píng)論。請(qǐng)幫我解決這些問(wèn)題CoDE->   $userdata = json_decode(file_get_contents('php://input'));    $userid = mysqli_real_escape_string($conn, $userdata->userid);    // =============================================================================    // ===========================Get Friends=======================================    // =============================================================================    $friends = "    SELECT  `friend_one`                FROM    `friends`                WHERE   `friend_two` = '$userid' AND `status` = '1'                UNION ALL                SELECT  `friend_two`                FROM    `friends`                WHERE   `friend_one` = '$userid' AND `status` = '1'            ";    $response = array();    $friendsq = mysqli_query($conn, $friends);    if(!$friendsq) {        $response['statusCode'] = 400;        $response['message'] = "failed to connect to backend. please contact developer";    }    $count = mysqli_num_rows($friendsq);    // =============================================================================    // ===========================No Friends=======================================    // =============================================================================    if($count == 0) {        $response['statusCode'] = 202;        $response['message'] = "No Friends to show the newsfeed";    } else {        $response['statusCode'] = 200;        $response['message'] = "Success";        $response['microblogs'] = array();        $name['comments'] = array();        // =============================================================================
查看完整描述

1 回答

?
GCT1015

TA貢獻(xiàn)1827條經(jīng)驗(yàn) 獲得超4個(gè)贊

而不是array_push($name['comments'], $res);,使用$name['comments'][] = $res;. 這記錄array_push.



查看完整回答
反對(duì) 回復(fù) 2022-07-16
  • 1 回答
  • 0 關(guān)注
  • 160 瀏覽

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)