Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Associative Array didn't work for me #17

Open
brilliant-smart opened this issue Jul 18, 2019 · 0 comments
Open

Associative Array didn't work for me #17

brilliant-smart opened this issue Jul 18, 2019 · 0 comments

Comments

@brilliant-smart
Copy link

public function services(){
$data=array(
'title'=>'Our Services',
'services'=>['Web Design','Programming','SEO']
);
return view('pages.services')->with($data);
Didn’t work for me on Laravel 5.8 If I use it in services page like this:
@section('content')

{{$title}}


@if (count($services) > 0)

@endif

@endsection()

But using associative array alone without the regular array like this worked
$data=array(
'title'=>'Our Services',
);
return view('pages.services')->with($data);

so, I had to comment this part out like this
@section('content')

{{$title}}


{{--@if (count($services)>0)

@endif--}}

@endsection()

And controller like this:

public function services(){
$data = array(
'title' => 'Services'
// 'services' => ['Web Design', 'Programming', 'Software Repairs']
);
return view('pages.services')->with($data);
}
}

This is the error message I get if I don’t comment those sections out
syntax error, unexpected ''services'' (T_CONSTANT_ENCAPSED_STRING), expecting ')'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant