• 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

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

Wordpress 'post_type_link' hides permalink

Get image type from base64 encoded src string

Laravel You requested 1 items, but there are only 0 items available

set mail driver dynamically from database for different email in notification

TesseractOCR not working for Laravel

Populate Dynamic Dropdowns List in Codeigniter

WooCommerce Additional Information - if empty, hide

"Mixed content blocked" when running an HTTP AJAX operation in an HTTPS page

printing all running session variable in laravel 5.1

how to remove white space in select 2

getting error while enter Command => php artisan route:list

VichUploaderBundle error "Expected argument of type "File", "NULL" given" when submitting the form without selecting any file

Pass an image through AJAX [duplicate]

Telegram bot doesn't answer

About Contact Privacy policy Terms and conditions