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

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

從 PHP 數(shù)組中獲取值并顯示它們

從 PHP 數(shù)組中獲取值并顯示它們

PHP
慕容3067478 2022-07-22 16:50:19
我正在做一個(gè)名為 FUND 的 crud,我可以使用 PHP implode方法在其中存儲(chǔ)許多東西以及一個(gè)數(shù)組。在那個(gè)數(shù)組中,我存儲(chǔ)了一些 FUND Id。這是數(shù)組創(chuàng)建代碼:<div class="custom-checkbox">  <label for="receive[]">Select Receive Funds</label>    @foreach($funds as $fund)     <div class="custom-control custom-checkbox">       <input class="custom-control-input" type="checkbox" name="receive[]" id="{{$fund->id}}" value="{{$fund->id}}">        <label for="{{$fund->id}}"  class="custom-control-label">{{$fund->title}}</label>     </div>   @endforeach這是商店代碼:public function store(Request $request){    $request->validate([        'title'=>'required',        'image'=>'required',        'description',        'available'=>'required',        'buy'=>'required',        'account',        'receive',    ]);    $image = $request->file('image');    $new_name = rand() . '.' . $image->getClientOriginalExtension();    $image->move(public_path('funds'), $new_name);    $form_data = array(        'title'=>$request->title,        'image'=>$new_name,        'description'=>$request->description,        'available'=>$request->available,        'buy'=>$request->buy,        'buyrate'=>$request->buyrate,        'sellrate'=>$request->sellrate,        'account'=>$request->account,        'receive'=>implode(',', (array)($request->receive)),    );    Fund::create($form_data);    return redirect('/admin/fund');}我正在使用 PHP explode方法在我的索引頁(yè)面上顯示該數(shù)組。$receive=[];foreach($funds as $fund){    $receive = explode(",",$fund->receive);}正如我提到的,我將基金 ID 存儲(chǔ)在該數(shù)組中。所以我想通過(guò)使用基金 ID 來(lái)顯示整行。為此,我正在使用以下查詢(xún):但是標(biāo)題圖片顯示是這樣的如何在沒(méi)有任何括號(hào)的情況下獲取 Title、Image 和其他人員?
查看完整描述

2 回答

?
冉冉說(shuō)

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

經(jīng)過(guò)幾次研究,我修復(fù)了它。這是答案:


@php $receives = \App\Fund::whereIn('id', $receive)->get(); @endphp

   @foreach($receives as $r)

       <a href="/multi" class="list-group-item">

           <p>

              <img src="{{ $r->image_url  }}" width="32px" height="32px"> {{ $r->title  }}

                <span class="pull-right text text-muted hidden-xs hidden-sm" style="font-size:11px;">

                    <small>Reserve: {{ $r->available }}<br>Exchange rate: {{ $r->buyrate }}</small>

                 </span>

            </p>

         </a>

   @endforeach


查看完整回答
反對(duì) 回復(fù) 2022-07-22
?
有只小跳蛙

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

嘗試使用標(biāo)簽而不是括號(hào)就像我在下一個(gè)例子中所做的那樣;

<img src="<?=$fund=\App\Fund::where(['id'=>$r])->get('image')?>"...

如果圖像的路線(xiàn)很好,它應(yīng)該可以工作。如果您在此之后有任何其他問(wèn)題,請(qǐng)告訴我:)


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

添加回答

舉報(bào)

0/150
提交
取消
微信客服

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

幫助反饋 APP下載

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

公眾號(hào)

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