• 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

XML to CSV with PHP converter [problem with images grabing]

How to get unique slug to same post-title for other time too?

Laravel 5 session not persisting after user is logged in

How to pass security cloudflare server with php curl

Is there an equivalent of DynamoDB on Azure as a PHP session Handler

Open a popup box after receiving result from ajax

hidden INPUT value not available in $_POST

Laravel passport auth token not working after moving to different server

MOODLE: What does it mean to aggregate h5p assets?

Whats the point of running Laravel with the command 'php artisan serve'?

generate an Excel file using PHP

Laravel-fopen: failed to open stream: Permission denied

Laravel unique validation on multiple columns

PHP password_verify

Sum column values from multiple arrays

About Contact Privacy policy Terms and conditions