Solved

Php Array Diff

Posted on 2016-11-01
3
27 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 108

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 108

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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Things That Drive Us Nuts Have you noticed the use of the reCaptcha feature at EE and other web sites?  It wants you to read and retype something that looks like this.Insanity!  It's not EE's fault - that's just the way reCaptcha works.  But it is …
Since pre-biblical times, humans have sought ways to keep secrets, and share the secrets selectively.  This article explores the ways PHP can be used to hide and encrypt information.
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

757 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now