亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

如何在PHP中打印對象數組的一個元素?

如何在PHP中打印對象數組的一個元素?

PHP
夢里花落0921 2022-09-17 15:32:23
當我在我的變量$veraplicacao上使用var_dump時,我得到的結果如下:object(Illuminate\Support\Collection)#351 (1) {    ["items":protected]=>        array(1) {            [0]=> object(stdClass)#357 (11) {                ["id"]=> int(1008)                ["created_at"]=> NULL                ["updated_at"]=> NULL                ["nomeempresa"]=> string(11) "Teste teste"                ["vagaaplicada"]=> string(6) "Testes"                ["statusaplicacao"]=> int(4)                ["pais"]=> string(6) "Brasil"                ["estado"]=> string(16) "Distrito Federal"                ["cidade"]=> string(12) "Plano Piloto"                ["textocompleto"]=> string(16) "Teste 123"                ["deleted_at"]=> NULL            }        }}我怎么能只得到“諾米姆普雷薩”值?當我嘗試時,我得到以下錯誤:$veraplicacao["nomeempresa"]Undefined index: nomeempresa當我嘗試時,我得到以下錯誤:$veraplicacao->nomeempresa屬性 [無名名]在此集合實例上不存在。當我嘗試時,我得到以下錯誤:$veraplicacao->nomeempresa不能使用 stdClass 類型的對象作為數組
查看完整描述

1 回答

?
大話西游666

TA貢獻1817條經驗 獲得超14個贊

要獲取您所需的屬性,可以先使用()

$veraplicacao->first()->nomeempresa;

有關集合的更多信息,我建議查看文檔。


或者,由于集合實現了數組訪問,因此您只需使用數組中值的索引:

$veraplicacao[0]->nomeempresa;


查看完整回答
反對 回復 2022-09-17
  • 1 回答
  • 0 關注
  • 123 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號