2

I have stored the FBIDs of a Facebook user's friends in a string in a mysql database. The string looks like this:

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

I am trying to use specific FBIDs in a view (call profile images, for instance). My question is, how do I do this in a Laravel 4 view? I am trying the following:

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

However, this just prints out the string with the other portion as text. I know this is incorrect, but I don't know how to perform a php call within the view in Laravel.

Thank you for your help.

EDIT:

Error Log:

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} [] []

2 Answers 2

5

You are trying to do two different things. Assuming that you want to get an array of friends - you do this:

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

You can then use the array like this:

@foreach ($array as $x)
    <p>This is another id: {{ $x }}</p>
@endforeach
Sign up to request clarification or add additional context in comments.

Comments

0

Move your curly braces to fully contain the PHP call:

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

3 Comments

We're trying to help you, but you aren't making it easy. Can you clarify what you mean by not working please? Are you getting an unexpected result (what is it exactly?) or an error message (what is it exactly?). Thanks
The page loads, but none of the CSS renders, and in the "title" portion, it says "Whoops", it doesn't read out an error, but it doesn't create the array either. Sorry for not being more explicit.
I just updated my question to include what I believe is the relevant log from app/storage/logs. If you think it's somewhere else, let me know.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.