Page 1 of 1

Passing a void to be used in an pChart object

Posted: Tue Apr 12, 2011 12:03 pm
by incubi
Although I'm working with pChart in this example I'm thinking this is a PHP question.

pChart uses arrays like this

Code: Select all

$MyData->addPoints(array(VOID,VOID,VOID,VOID,900,890,800,780,500,600,400), Data);  
The voids are breakpoints in the graphs.

I'm trying to pass the VOID to addPoints in a function like below. Doing so seems to put the VOID in the array as a string and as you can see from the code above this doesn't work.

Code: Select all

temperature[] = 'VOID';
$temperature[] = 'VOID';
$temperature[] = 'VOID';
$temperature[] = '20';
$temperature[] = '10';
$temperature[] = '50';
$temperature[] = '30';

exampleg($temperature);

function exampleg($temperature )
{
    $MyData->addPoints($temperature, "Data");
}
I understand if this is a pcart issue and not a direct php question but any help would be great!

Thanks
Lee

Re: Passing a void to be used in an pChart object

Posted: Tue Apr 12, 2011 3:04 pm
by AbraCadaver
I would try null or false. Don't quote them. Or not knowing anything about pChart and what it considers VOID, you could define a constant as an empty string:

Code: Select all

define('VOID', '');
Not sure.

Re: Passing a void to be used in an pChart object

Posted: Tue Apr 12, 2011 3:45 pm
by incubi
Nice! Seems to work well :) Much better then the workaround I did in the function.

Code: Select all

	
foreach($temperature as &$val)
{
    if($val == "placeholder")
    $val = VOID;
}
unset($val);
Thanks for the help,
Lee