So, i am trying to display a chart where the profit and payout is rendering on a chart. If there is a no profit and payout value in chart then it should show 0.
I have an array with values of profit and payout with hour. Now i want to replace that array with an existing array of 0 values.
Here is my code
$a1=array();
for($i=0,$i<=24,$i++){
$a1['hour']=$i;
$a1['payout']='0';
$a1['profit']='0';
}
$a2=array();
$a2['hour']='2';
$a2['profit']='300';
$a2['payout']='100';
print_r(array_replace($a1,$a2));
There is something wrong with this code. Can any1 tell me what i am doing wrong?
forloop? In the end$a1['hour']will be 24 always.$a1['hour']cannot take multiple values. Thats why i asked whats the purpose of forloop. It will be better if you can write output like output: Array( 0=> something)(not in words)