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

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

在 Laravel 刀片中顯示 URL 結尾 - Laravel 5.8

在 Laravel 刀片中顯示 URL 結尾 - Laravel 5.8

PHP
慕勒3428872 2021-11-26 19:13:12
我收到來自 API 的響應,其中包含如下鏈接。 ['link'] => items/892320.有幾個鏈接,所以我循環(huán)獲取所有鏈接。在我看來,我只想892320在刀片中顯示 URL 的最后一部分,如下所示看法@foreach($export_details['body']['data'] as $export_detail)<div class="view">    <div class="time">0:{{$export_detail['duration']}}</div>      <div class="time">0:{{$export_detail['name']}}</div>      <iframe src="{{$export_detail['link']}}" width="345" height="200" frameborder="0" allow="autoplay; fullscreen" allowfullscreen></iframe></div>@endforeach控制器public function index(){    $response = $client->request('/users/id/items', array(), 'GET');    $results =  json_decode(json_encode($response),true);    $export_details = $results;    return view('home',compact('export_details'));  }       如何僅將 url 的最后一部分顯示為 iframe 源?
查看完整描述

2 回答

?
茅侃侃

TA貢獻1842條經(jīng)驗 獲得超21個贊

假設鏈接將始終遵循模式 'items/{identifier}'

用于ltrim從鏈接開頭刪除“items/”。

ltrim($export_detail['link'], 'items/')


查看完整回答
反對 回復 2021-11-26
?
12345678_0001

TA貢獻1802條經(jīng)驗 獲得超5個贊

如果您從 API 接收到的所有鏈接都遵循相同的格式,您可以通過稍微調(diào)整控制器以在將鏈接發(fā)送到視圖之前對其進行按摩來實現(xiàn)這一點:


public function index(){

  $response = $client->request('/users/id/items', array(), 'GET');

  $results =  json_decode(json_encode($response),true);

  $export_details = $results;

  $export_details['link'] = array_slice(explode('/', $export_details['link']), -1)[0];

  return view('home',compact('export_details'));  

以下是explode()和array_slice() PHP 函數(shù)的鏈接,供您參考。


查看完整回答
反對 回復 2021-11-26
  • 2 回答
  • 0 關注
  • 183 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

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

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網(wǎng)微信公眾號