I'm trying to pass an array to a class constructor, and for some reason the constructor receives different arrays than the ones I'm sending. The code building the 2 arrays and sending them:
$exportArray=array();
foreach($new->arr as $ar){
$values[]=intval($ar[4]);
$dates[]=strtotime($ar[1]);
$exportArray[]=array($ar[5],$ar[0],$ar[2],$ar[3],$ar[1]);
}
$new->query="SELECT distinct c_name,date,m_name,t_amount,t_id FROM transport,customer,driver,material WHERE"
. " customer.c_id=transport.c_id AND material.m_id=transport.m_id AND transport.d_id=$name ORDER BY date DESC LIMIT $lim";
//var_dump($new->query);
$new->again();
foreach($new->arr as $ar){
echo "<tr><td><a href='customers.php?c_name=$ar[0]'>$ar[0]</a></td><td>$ar[1]</td><td><a href='materials.php?m_name=$ar[2]'>$ar[2]</a></td><td>$ar[3]</tr>";
//var_dump($ar);
}
?>
</table>
<?php
if(isset($lim)&&$lim!="1"){
$qr=new query("SELECT last FROM graph");
$last=$qr->arr[0][0];
var_dump($values);
var_dump($dates);
$graph1=new graphs($dates,$values,"Deliveries With Respect To Dates","driver");
$graph1->getGraph("date");
$qr->again();
The class constructor receives them and performs checks:
class graphs{
public $xtype=NULL;
public $ytype=NULL;
public $graph=NULL;
private $xs=array();
private $ys=array();
public $type=NULL;
public function __construct($arr1,$arr2,$title,$type){
if(!is_array($arr1)||!is_array($arr2)){
die("in order to see the graph, you need more than one result!");
}
elseif(count($arr1)<=1||count($arr2)<=1){
var_dump($arr1);
var_dump($arr2);
die("in order to see the RELEVANT graph, you need more than one result!");
}
$this->title=$title;
$this->xs=$arr1;
$this->ys=$arr2;
$this->graph= new Graph(600,400,'auto');
$this->graph->SetScale("textlin");
$this->graph->SetShadow();
$this->graph->title->Set($this->title);
$this->graph->title->SetFont(FF_ARIAL,FS_NORMAL,9);
$this->graph->xaxis->setTickLabels($arr1);
if($type=="driver"){
$this->type=1;
}
elseif($type=="customer"){
$this->type=2;
}
elseif($type=="material"){
$this->type=3;
}
}//construct
Getting this on browser(first 2 dumps are what i'm sending,second ones are the ones the class is dumping):

customers, which isn't present in your input data at all. phpfiddle.org/main/code/szvx-6bytprint_r()right at the top of the constructor? (Also comment all other code lines out)