• 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

GuzzleHttp Hangs When Using Localhost

Store multiple fields in JSON column (Nova CMS)

How to debug in WooCommerce 3+

Is there a way to use Foundry Model for Authentification inside Functional Tests?

Hi, I am making a contact form thingy, and my php isn't working any reason why?

How do I Post to .txt document before form submits

PHP Find Array Index value in multi-line array

PHP: Calling MySQL Stored Procedure with Both INPUT AND OUTPUT Parameters (NOT "INOUT")

"Mixed content blocked" when running an HTTP AJAX operation in an HTTPS page

Laravel 5 issue with wherePivot

Is there a way to use the same parameter into multiple place in the same query with Eloquent? [duplicate]

Read users and passwords from a txt file

Composer fails with kylekatarnls/update-helper on new homestead

Losing session data after POST from third party website

Group data in a multidimensional array based on two columns

About Contact Privacy policy Terms and conditions