• 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

Laravel 4 Redirect::back() not going to previous page (refreshing current page)

LARAVEL: How to fetch id dynamically in a query builder?

Cut an arabic string

Laravel: Why is my variable not being set while it's in the construct function of the controller?

laravel 5.6 bulk inserting json data

CONCAT columns with Laravel 5 eloquent

How in Laravel run JavaScript code stored in php variable?

Symfony/Form add attribute based on the data

Search for array row with specific column value and return another value from qualifying row

Utf8 encoding issue with Laravel

How to add a custom field to all Woocommerce attribute terms using add_action

How to get quarter for future date using Carbon?

how to fix Service provider class not found when using repository?

how to fix Service provider class not found when using repository?

Is it possible to change the table name in the migration file-laravel

About Contact Privacy policy Terms and conditions