• 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 can I get data from PHP to Android TextView?

Symfony 4: how to allow dynamic values for array nodes in bundle configuration?

api response laravel doesn't show

Star and Half Star Rating in Laravel

browsersync doesn't work with XAMPP

Image upload not working through ajax Laravel

Laravel 8 factory state afterCreating

Class AppHttpControllersUserController Does Not Exist

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

Input and output values for php into the browser?

Star and Half Star Rating in Laravel

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

Convert date and time to Jalali in Laravel

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

MySQL/PHP - Web Based Game -User specific inventory table or 1 giant table? Another option?

About Contact Privacy policy Terms and conditions