gpt4 book ai didi

php - 在 Laravel 4 的 View 中使用 explode

转载 作者:行者123 更新时间:2023-12-02 04:58:34 25 4
gpt4 key购买 nike

我已将 Facebook 用户好友的 FBID 存储在 mysql 数据库中的字符串中。字符串看起来像这样:

"fbid1,fbid2,fbid3...etc..."

我正在尝试在 View 中使用特定的 FBID(例如,调用配置文件图像)。我的问题是,如何在 Laravel 4 View 中执行此操作?我正在尝试以下操作:

array = explode(",", {{ Auth::user()->friend_ids_unpacked}});

但是,这只是将字符串的另一部分作为文本打印出来。我知道这是不正确的,但我不知道如何在 Laravel 的 View 中执行 php 调用。

感谢您的帮助。

编辑:

错误日志:

Stack trace:
#0 /Applications/MAMP/htdocs/crowdsets/laravel-master/app/storage/views/2ed7fc8952dab08cf4cb4f4e3d40d1ab(119): Illuminate\Exception\Handler->handleError(8, 'Array to string...', '/Applications/M...', 119, Array)
#1 /Applications/MAMP/htdocs/crowdsets/laravel-master/bootstrap/compiled.php(9032): include('/Applications/M...')
#2 /Applications/MAMP/htdocs/crowdsets/laravel-master/vendor/laravel/framework/src/Illuminate/View/Engines/CompilerEngine.php(45): Illuminate\View\Engines\PhpEngine->evaluatePath('/Applications/M...', Array)
#3 /Applications/MAMP/htdocs/crowdsets/laravel-master/bootstrap/compiled.php(8925): Illuminate\View\Engines\CompilerEngine->get('/Applications/M...', Array)
#4 /Applications/MAMP/htdocs/crowdsets/laravel-master/bootstrap/compiled.php(8916): Illuminate\View\View->getContents()
#5 /Applications/MAMP/htdocs/crowdsets/laravel-master/bootstrap/compiled.php(9510): Illuminate\View\View->render()
#6 /Applications/MAMP/htdocs/crowdsets/laravel-master/bootstrap/compiled.php(9058): Illuminate\Http\Response->setContent(Object(Illuminate\View\View))
#7 /Applications/MAMP/htdocs/crowdsets/laravel-master/bootstrap/compiled.php(4921): Symfony\Component\HttpFoundation\Response->__construct(Object(Illuminate\View\View))
#8 /Applications/MAMP/htdocs/crowdsets/laravel-master/bootstrap/compiled.php(7811): Illuminate\Routing\Router->prepare(Object(Illuminate\View\View), Object(Illuminate\Http\Request))
#9 /Applications/MAMP/htdocs/crowdsets/laravel-master/bootstrap/compiled.php(4762): Illuminate\Routing\Route->run(Object(Illuminate\Http\Request))
#10 /Applications/MAMP/htdocs/crowdsets/laravel-master/bootstrap/compiled.php(481): Illuminate\Routing\Router->dispatch(Object(Illuminate\Http\Request))
#11 /Applications/MAMP/htdocs/crowdsets/laravel-master/bootstrap/compiled.php(470): Illuminate\Foundation\Application->dispatch(Object(Illuminate\Http\Request))
#12 /Applications/MAMP/htdocs/crowdsets/laravel-master/public/index.php(49): Illuminate\Foundation\Application->run()
#13 {main} [] []

最佳答案

您正在尝试做两件不同的事情。假设您想要获得一群 friend - 您可以这样做:

<? $array = explode(",", Auth::user()->friend_ids_unpacked); ?>

然后您可以像这样使用数组:

@foreach ($array as $x)
<p>This is another id: {{ $x }}</p>
@endforeach

关于php - 在 Laravel 4 的 View 中使用 explode ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17505848/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com