• 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

Warning: A non-numeric value encountered

SlimExceptionHttpNotFoundException

get folder directory from input type file - PHP

Using spatie/media-library, how to rename a collection of uploaded files?

Session timeout in Yii2

How to get the survey List from surveygizmo API in the Postman?(Trial Version)

Artisan, creating tables in database

xdebug 3 not working in ubuntu 20.04 with docker

how to see if database exists with PDO [duplicate]

laravel controller function parameters

Twig - How to check if variable is a number / integer

Don't show recurring price for WooCommerce subscriptions worth 0$

PHP Slim Framework request using withAttribute error

Laravel 5 session not persisting after user is logged in

SQLSTATE[22007]: Invalid datetime format: 1366 Incorrect integer value: 'column_name' in Laravel

About Contact Privacy policy Terms and conditions