• 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

file_put_content...fail to open stream:Permission denied in Laravel 5

How to use a PHP MVC Controller, one thats invoked by calling a URL, to call and execute more than one function? [duplicate]

retrieve data from database using session

Laravel s3 upload file with metadata using pre-signed url

Laravel post contact form giving me error 419

How to Generate PDF invoice to XML format using mPDF

laravel 5.6 bulk inserting json data

Pass an image through AJAX [duplicate]

Why isn't my PHP exception working?

GuzzleHttp Hangs When Using Localhost

Is it possible to re-use an array taken from PHP via JSON in a $.ajax function?

Laravel PackageManifest.php: Undefined index: name

get data-value with variable value

Create tags in laravel post publishing

Add bold text and line break into Laravel Notification Email

About Contact Privacy policy Terms and conditions