• 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

Form repeater send wrong data with last element in Laravel

How to extract price from given url using Xpath?

CodeIgniter force_download is not working

How should I get started using PHPUnit as a testing framework for a bunch of functions and classes I have already made?

dockerizing Laravel + vue

enroll_table three field fetch to payment form to create payment field in laravel 5.5

laravel 5.6 bulk inserting json data

How to access a var with "-" in PHP [duplicate]

Yii Ajax Submit button

Laravel print last executed SQL query with Query log

Access denied for user 'homestead'@'localhost' (using password: YES)

How to get result of the formula on import xlsx with maatwebsite using Laravel? I get formula and not value of the formula

"There is no active transaction" when refreshing database in Laravel 8.0 test

Laravel display validation error

Unable to guess the mime type as no guessers are available Laravel 5.2

About Contact Privacy policy Terms and conditions