Solved

Php Array Diff

Posted on 2016-11-01
3
46 Views
Last Modified: 2016-11-01
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
Comment
Question by:pc-buddy
  • 2
3 Comments
 
LVL 109

Accepted Solution

by:
Ray Paseur earned 500 total points
ID: 41868765
When your script uses echo to print out an array, PHP unhelpfully substitutes the value "Array."  Try using print_r($totals) instead.
0
 

Author Closing Comment

by:pc-buddy
ID: 41868772
Yeah just figured that out haha, thanks
0
 
LVL 109

Expert Comment

by:Ray Paseur
ID: 41868797
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

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Foreword (July, 2015) Since I first wrote this article, years ago, a great many more people have begun using the internet.  They are coming online from every part of the globe, learning, reading, shopping and spending money at an ever-increasing ra…
These days socially coordinated efforts have turned into a critical requirement for enterprises.
The viewer will learn how to dynamically set the form action using jQuery.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

774 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question