• 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

What will the best solution for this multiple optional filter?

Image upload not working through ajax Laravel

Multiply each value in array using array_map function

Add Metadata, headers (Expires, CacheControl) to a file uploaded to Amazon S3 using the Laravel 5.0 Storage facade

Yii2 redirecting to previous page after login

Yii Ajax Submit button

Is there a way to use the same parameter into multiple place in the same query with Eloquent? [duplicate]

array_key_exists(): The first argument should be either a string or an integer

Combine array with same value and add other [duplicate]

MySQL/PHP - Web Based Game -User specific inventory table or 1 giant table? Another option?

Jquery DataTables: Data not displaying in table via Ajax

CSS file not imported in laravel blade view

Laravel print last executed SQL query with Query log

How to pass data to all views in Laravel 5?

Unable to uninstall brew php from homebrew

About Contact Privacy policy Terms and conditions