Iはアレイ現在、この出力を印刷する機能を有する。phpの配列から列/ノードを取り除くにはどうしたらいいですか?
{ "player_id": "2"}、{ "player_id": "31"}、{ "player_id": "31"}、{」 「player_id」:「32」}
ノード「player_id」を削除して、数字の配列が残っている必要があります。
これは私の現在のコードである:
specificCommunity.php:
$communityPlayerIds = array();
$communityPlayersIds = $dao->getSpecificCommunity($id)
MySQLDao.php
public function getSpecificCommunity($id)
{
$returnValue = array();
$sql = "SELECT community_players.player_id\n"
. "from community_players\n"
. "where community_players.community_id = '".$id."'";
$result = $this->conn->query($sql);
if($result != null && (mysqli_num_rows($result) >= 1)){
while($row = $result -> fetch_array(MYSQLI_ASSOC)){
if(!empty($row)){
$returnValue[] = $row;
}
}
}
これはバックコードが継続specificCommunity.phpの配列を返す:
を$in_statement = array();
foreach($communityPlayersIds as $player_id)
{
$in_statement[] = $player_id->player_id;
echo json_encode(array($in_statement));
}
しかし、これは動作し、リターンしません:
お知らせ:行35 に/var/sites/q/quasisquest.uk/public_html/KeepScore/specificCommunity.phpで非オブジェクトのプロパティを取得しようとすると[ [null]] Notice:/var/sites/q/quasisquest.uk/public_html/KeepScore/specificCommunity.php 35行目の非オブジェクトのプロパティを取得しようとしています [[null、null]] 通知: /var/sites/q/quasisquest.uk/public_html/KeepScore/specificCommunity.php 35行目の非オブジェクトのプロパティを取得 [[null、null、null]] 注意:非オブジェクトのプロパティを取得しようとしています/var/sites/q/quasisquest.uk/public_html/KeepScore/specificCommunity.php on line 35 [[NULL、NULL、NULL、NULL]]
'も'エコーjson_encode(配列($のin_statement))を使用し '$のplayer_id [ 'player_id']と試みる;'外ループ、または最良のオプションは 'print_r($ communityPlayersIds);' chk thisと結果を共有します – devpro
それはそれでした!乾杯、私は答えに変換しているいくつかのより多くの提案があることを知っておいて良いです。 – RDowns
。 – devpro