0

I have an array of array object data but I am getting an error when I try to print this in view. Here is my data:

Array ( [0] => stdClass Object ( [id] => 2 [user_id] => 4 [user_name] => Infinity Resort [listing_name] => 200 Hour Yoga Teacher Training [course] => 200 Hour Yoga Teacher Training [course_duration] => [retreat_type] => Featured [start_date] => [end_date] => [last_day_to_register] => [contact_person] => Infinity Resort [website] => http://bookyogatrips.com [contact_number] => 265478541 [address1] => Kathmandu ,Bagmati Nepal 4460 [address2] => [country] => Thailand [country_id] => 217 [state] => Bangkok [state_id] => 3528 [city] => Bangkok [pincode] => 44600 [rooms_type] => [overview] =>
hjkhjkhj

[program_description] =>
kjhkjhkhj

[curriculum] =>
hjkjhk

[why_choose] => [area_destination] =>
hkjhkhjk

[location] => [about_food] =>
hjkjhkjhk

[program_special] => [inclusions] => [food] => Vegetarian,Vegan [accommodaion_image] => [currency] => [itineraries] => [local_info] => [weather_information] => [seasonal_information] => [meta_title] => [meta_description] =>
hkjhkjhkh

[meta_keyword] =>
ghjghj

[service_type] => Yoga TTC [course_cat] => 2 [media] => 101839ManasluTrek.jpg [approved] => 1 [created_at] => 2018-11-14 10:41:50 [updated_at] => 2018-11-14 10:41:50 [_token] => ) )

How can I print this data in a Laravel view?

3
  • Can you post the code that you have tried? Commented Jan 21, 2019 at 8:31
  • Can you share view file code or given error? Commented Jan 21, 2019 at 8:41
  • yes sure... i have put my controller code after aarray data..please check Commented Jan 21, 2019 at 8:42

2 Answers 2

1

Please try below code

foreach ($objdata as $data) {
    $data = (array) $data
    // now $data is array 
}
Sign up to request clarification or add additional context in comments.

Comments

0

If it's array of objects then you can give a try like below code:

foreach($arrayObjects as $object){
     ...
     $object->id; 
     $object->user_id; 
     ...
 }

1 Comment

Good to 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.