• 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

Add a text next to stock quantity if it is less than 10 in Woocommerce single product

Laravel 5.1 xmlHttpRequest AJAX POST TokenMismatchException

Send same name multiple checkbox values via ajax

Webscraping Symfony/Panther: Can't get HTML

PHP: PDO + CSV export not downloading (headers issue?)

How to get quarter for future date using Carbon?

Combine multiple columns into an array as one of the key in a results set

add_action() function in wordpress not working [duplicate]

Laravel Gates using model and returns "Using $this when not in object context" Line 28 of AzureUser model

How to get median and quartiles/percentiles of an array in JavaScript (or PHP)?

Laravel 5.1 xmlHttpRequest AJAX POST TokenMismatchException

Natural ORDER in Laravel Eloquent ORM

Get sum of arrays inside array

Session timeout in Yii2

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

About Contact Privacy policy Terms and conditions