2

我已将 Facebook 用户朋友的 FBID 存储在 mysql 数据库中的字符串中。字符串如下所示:

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

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

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

但是,这只是将字符串与其他部分作为文本打印出来。我知道这是不正确的,但我不知道如何在 Laravel 的视图中执行 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} [] []
4

2 回答 2

5

您正在尝试做两件不同的事情。假设您想结交一群朋友-您可以这样做:

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

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

@foreach ($array as $x)
    <p>This is another id: {{ $x }}</p>
@endforeach
于 2013-07-07T02:48:16.853 回答
0

移动花括号以完全包含 PHP 调用:

{{ $array = explode(",", Auth::user()->friend_ids_unpacked); }}
于 2013-07-06T19:00:30.373 回答