Laravel add new item to foreach loop from outside
I am curious. Is Laravel giving us an easier way to add foreign items to foreach array? For example i have:
$video_url = Video::orderBy('created_at', 'desc')->first()->url;
$cut_head = str_after($video_url, 'https://www.youtube.com/watch?v=');
$cut_tail = str_before($cut_head, '&');
It works as i think. Cutting head and tail. But in my videos loop. There is no cropped video url link.
$videos = Video::orderBy('created_at', 'desc')->get();
$videos is using in my view. Inside a foreach loop. How can i entegrate the cropped url_link to the foreach loop.
Thanks an advance.
from Laravel Questions and Answers https://laravelquestions.com/php/laravel-add-new-item-to-foreach-loop-from-outside/
via Lzo Media
No comments:
Post a Comment