Passing a void to be used in an pChart object

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
incubi
Forum Contributor
Posts: 119
Joined: Mon Dec 07, 2009 1:47 pm

Passing a void to be used in an pChart object

Post 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
User avatar
AbraCadaver
DevNet Master
Posts: 2572
Joined: Mon Feb 24, 2003 10:12 am
Location: The Republic of Texas
Contact:

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

Post 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.
mysql_function(): WARNING: This extension is deprecated as of PHP 5.5.0, and will be removed in the future. Instead, the MySQLi or PDO_MySQLextension should be used. See also MySQL: choosing an API guide and related FAQ for more information.
incubi
Forum Contributor
Posts: 119
Joined: Mon Dec 07, 2009 1:47 pm

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

Post 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
Post Reply