• 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

Is there a way to correctly use sanitize_text_field and wp_unslash that doesn't cause psalm to error with "expects string, possibly different type"

Laravel 8: Array to string conversion while calling route:list

301 Redirect to remove query string on homepage only

How to generate QR CODE for dynamic generating link and logo using Simple QrCode in laravel?

Yoast SEO (WordPress Plugin) - Get plugin generated data manually

Laravel Displaying image from database

curl returning 301 error after migrating to https

How to make a foreign key not using primary key

Navigation idle on content download

Show rotation of tweets using current day of month

WHERE IN array binding in DB::raw laravel 5.4

Google Gmail API - How to login programatically?

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

Lexik JWT authentication problem "Invalid credentials"

How to reset Laravel AuthManager/guards in between API calls in tests?

About Contact Privacy policy Terms and conditions