• 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

Converting array to string and then back in PHP

Add and update products to session cart in Laravel

WAMP Virtual Host not working

XML to CSV with PHP converter [problem with images grabing]

Querying only one row from a one to many relationship laravel

PDOException: PDO::__construct(): php_network_getaddresses: getaddrinfo failed: no such host known

Laravel/docker-compose/redis - Class 'Redis' not found

Laravel Nova Dependency Container what are the allowed resource properties other than id in dependsOn

Laravel update hasMany relationship using saveMany

Eloquent insert id with sequence next value

Why "Class 'GuzzleHttpClient' not found" even after Installing it in Laravel?

Yii2 redirecting to previous page after login

java URL working on browser but not in client program

What's the net::ERR_HTTP2_PROTOCOL_ERROR about?

I want a way to give path to my files which are outside of public folder in laravel

About Contact Privacy policy Terms and conditions