Hi,
here is a simple php code that I am trying to get to work for a script of mine. Here is the code:
<html><body>
<?
$sales = Array('template1' => '4', 'template2' => '2');
$calls = Array('template2' => '56', 'template3' => '76');
if(is_array($sales) || is_array($calls)){
$alltemplates = Array();
}
if(is_array($sales)){
$temparray = array_keys($sales);
array_push($alltemplates, $temparray);
}
if(is_array($calls)){
$temparray = array_keys($calls);
array_push($alltemplates, $temparray);
}
if(is_array($alltemplates)){
$alltemplates = array_unique($alltemplates);
while(list($key, $value) = each($alltemplates)){
?>
<? echo $value; ?>: <? echo $sales[$value]; ?>, <? echo $calls[$value]; ?><br>
<?
}
}
?>
</body></html>
When I run that code, I get the following output:
Array:
Warning: Illegal offset type in /www/website.com/test.php on line 20
,
Warning: Illegal offset type in /www/website.com/test.php on line 20
I simply do not get why my array gets messed up and outputs "Array" as the first value in the $alltemplates array. Could someone help me figure out what could cause this?
What I want to do is pretty simple after all, I want to print every template name along with the number of calls and the number of sales associated with it. For this I want to get all the keys from my two arrays, and go through them and output the corresponding sales and calls (if any).
If someone could help me find what causes problems in my code, please let me know. It would be greatly appreciated!
Thanks!
Jerome