• 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

Correct way to use LIKE '%{$var}%' with prepared statements?

How to get values inside <![CDATA[values]] > using php DOM?

get attribute from class not working php 7

Passing a boolean value from checkbox in Laravel form

Laravel Carbon throws error The format separator does not match

Remove product downloads section in woocommerce email notifications

PHP Include for HTML?

Laravel - Browser displays message again when I press back button

How to get AJAX to post on second page?

How to unlink image from folder?

Yii2: How do I debug console commands?

Zig-zag scan an N x N array

Symfony redirect if already loggedin from login page

How to KeyBy where multiple items have the same key

Uncaught TypeError: Cannot read property 'length' of null when retrieving tags from wp

About Contact Privacy policy Terms and conditions