Welcome Guest, Not a member yet? Register   Sign In
Array to string conversion
#1

(This post was last modified: 07-09-2020, 10:59 AM by jreklund.)

I am trying to print the values from my array:

print_r($google['Google_assigned_previous_day']); -> this works but prints:
Array ( [0] => Array ( [sale] => 0.00 ) ). I want to be able to get the value only. The 0.00

foreach($google['Google_assigned_previous_day'] as $result['Google_assigned_previous_day']) {
  echo $result;
}

I try the code above but I get the error:

Severity: Notice
Message: Array to string conversion§
Filename: views/welcome_message.php
Line Number: 66

Can someone help please?

Thanks
Reply
#2

Foreach works this way.

Code:
foreach($google['Google_assigned_previous_day'] as $array) {
  echo $array['sale'];
}
Reply
#3

(07-09-2020, 11:01 AM)jreklund Wrote: Foreach works this way.

Code:
foreach($google['Google_assigned_previous_day'] as $array) {
  echo $array['sale'];
}


Thank you that worked!
I dont remember including "sale" anywhere. Would you mind explaining where that comes from? Thanks!
Reply
#4

No idea, you said it where there when you dumped it.

Array ( [0] => Array ( [sale] => 0.00 ) )
Reply
#5

(07-09-2020, 10:53 AM)andreaccident Wrote: Array ( [0] => Array ( [sale] => 0.00 ) ). I want to be able to get the value only. The 0.00


Right here mate.
Website: marcomonteiro.net  | Blog: blog.marcomonteiro.net | Twitter: @marcogmonteiro | TILThings: tilthings.com
Reply




Theme © iAndrew 2016 - Forum software by © MyBB