• Categories
    • PHP
    • phpMyAdmin
    • PHPMailer
    • FFMpeg
    • PHPEXcel
    • PHPDoc
    • PHPUnit
    • CakePHP
    • CakePHP 2.0
    • Cake PHP 2.1
    • CakePHP Model
    • Facebook PHP SDK
    • composer-php
    • PHP 7
    • PHP GD
    All Categories
  • About

Why do I have invalid argument supply for foreach in Laravel for json response? [duplicate]

phpjqueryajaxlaravellaravel-5


PHP Snippet 1:

//...
$product  = json_decode($request->product, true);
//...

PHP Snippet 2:

 public function dopayment(Request $request) {

            $input = $request->all();

            $product = json_decode($request->product);


            foreach ($product as $single) {
                # code...

                print_r($single->name);
            }

           print_r($product);
            exit;
        }

PHP Snippet 3:

if (is_array($product ) || is_object($product ))
{
    foreach($product as $arrayItems){
      // Perform x.
    }
}

Related Snippets

Why "Class 'GuzzleHttpClient' not found" even after Installing it in Laravel?

PHP-Sort array based on another array?

is there any way to validate a field that sometime is File(image) && sometime is String(Src of same image)

Return new collection without modifying original collection

jQuery Ajax Post with data

phpMyAdmin ERROR: mysqli_real_connect(): (HY000/1045): Access denied for user 'pma'@'localhost' (using password: NO)

Laravel 5 session not persisting after user is logged in

How to convert binary string to normal string in php

Laravel set default language not working

Laravel 5: Is there a non-case sensitive way to sort a collection by an attribute?

Laravel Mixing of GROUP columns (MIN(),MAX(),COUNT(),...) on a sub query with "ROW_NUMBER() OVER PARTITION"

How can I get user id from session in javascript?

Unable to Edit config.inc.php

How to set a domain name with php artisan serve

How to create custom authentication in laravel 8?

About Contact Privacy policy Terms and conditions