• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 89
  • Last Modified:

Php Array Diff

Hi,

I have 2 arrays

$dates
Array
(
    [0] => 2016-11-01
    [1] => 2016-11-08
    [2] => 2016-11-15
    [3] => 2016-11-22
    [4] => 2016-11-29
)

$holidays
Array
(
    [0] => 2016-11-07
    [1] => 2016-11-08
    [2] => 2016-11-09
    [3] => 2016-11-10
    [4] => 2016-11-11
)

$totals =  array_diff($dates, $termtimedates) . '<br><br>';
			
			echo $totals . '<br><br>';

Open in new window


All I get back is word "Array"

Any ideas thanks
0
pc-buddy
Asked:
pc-buddy
  • 2
1 Solution
 
Ray PaseurCommented:
When your script uses echo to print out an array, PHP unhelpfully substitutes the value "Array."  Try using print_r($totals) instead.
0
 
pc-buddyAuthor Commented:
Yeah just figured that out haha, thanks
0
 
Ray PaseurCommented:
This happens any time PHP does type-coercion from Array to String (not just in echo).  It's a terrible design flaw, but it's too late to fix it now that it's been baked into the language.  A more appropriate approach would be to trigger a warning!
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now