Forum Moderators: coopster

Message Too Old, No Replies

Sending array to function problem

Sending array to function problem

         

kientructayho

7:52 am on Jan 18, 2020 (gmt 0)

5+ Year Member



Hello all,

echo $events; //THIS ECHOS THE ARRAY TO SCREEN

$events = [$events]; // HERE the variable has the correct array info, but it only works if i Copy and Paste the array from screen to $events variable

echo build_html_calendar($_GET['y'], $_GET['d'], $events);

The array has info like this and it works if i replace the second line to this

$events = ['2018-07-01'=> ['text'=> "
",'href' => "#C13757"],'2018-07-02'=> ['text'=> "08:09:56
16:05:00",'href' => ""],'2018-07-03'=> ['text'=> "08:13:21
16:04:52",'href' => ""],'2018-07-04'=> ['text'=> "08:09:06
16:05:34",'href' => ""],'2018-07-05'=> ['text'=> "08:10:22
16:07:56",'href' => ""],'2018-07-06'=> ['text'=> "08:08:49
15:56:35",'href' => ""],'2018-07-07'=> ['text'=> "
",'href' => "#C13757"],'2018-07-08'=> ['text'=> "
",'href' => "#C13757"],'2018-07-09'=> ['text'=> "08:16:21
16:03:10",'href' => ""],'2018-07-10'=> ['text'=> "08:03:25
16:07:58",'href' => ""],'2018-07-11'=> ['text'=> "08:06:46
11:37:30",'href' => ""],'2018-07-12'=> ['text'=> "08:02:38
09:30:23",'href' => ""],'2018-07-13'=> ['text'=> "08:07:21
16:01:51",'href' => ""],'2018-07-14'=> ['text'=> "
",'href' => "#C13757"],'2018-07-15'=> ['text'=> "
",'href' => "#C13757"],'2018-07-16'=> ['text'=> "08:22:02
11:24:37",'href' => ""],'2018-07-17'=> ['text'=> "08:12:35
16:01:42",'href' => ""],'2018-07-18'=> ['text'=> "
",'href' => "#C13757"],'2018-07-19'=> ['text'=> "
",'href' => "#C13757"],'2018-07-20'=> ['text'=> "08:13:26
16:00:05",'href' => ""],'2018-07-21'=> ['text'=> "
",'href' => "#C13757"],'2018-07-22'=> ['text'=> "
",'href' => "#C13757"],'2018-07-23'=> ['text'=> "
",'href' => "#C13757"],'2018-07-24'=> ['text'=> "
",'href' => "#C13757"],'2018-07-25'=> ['text'=> "
",'href' => "#C13757"],'2018-07-26'=> ['text'=> "
",'href' => "#C13757"],'2018-07-27'=> ['text'=> "
",'href' => "#C13757"],'2018-07-28'=> ['text'=> "
",'href' => "#C13757"],'2018-07-29'=> ['text'=> "
",'href' => "#C13757"],'2018-07-30'=> ['text'=> "08:07:20
16:02:57",'href' => ""],'2018-07-31'=> ['text'=> "08:02:42
16:03:12",'href' => ""]]

So what is missing in the variable to make it read the array correctly?

Thanks in adance!

phranque

8:06 am on Jan 18, 2020 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



welcome to WebmasterWorld [webmasterworld.com], kientructayho!

have you tried using an editor with syntax highlighting?
that might help reveal the error.

JorgeV

10:45 am on Jan 18, 2020 (gmt 0)

WebmasterWorld Senior Member 5+ Year Member Top Contributors Of The Month



Hello-

What's your problem? (sorry I didn't get it)

robzilla

2:20 pm on Jan 18, 2020 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



$events = [$events];

If $events already is an array, why do you create another array around it? Maybe just drop that whole line?

JorgeV

5:13 pm on Jan 18, 2020 (gmt 0)

WebmasterWorld Senior Member 5+ Year Member Top Contributors Of The Month



echo $events; //THIS ECHOS THE ARRAY TO SCREEN

The thing is, if it echoes the array values, then it means $events is not an array, but a string.

If you "echo" a variable which is an array, it will just print the word "Array", and not the value.

May be this is it the problem? your $event variable is a string, and not an array?