last day (14 days later) » 

06:20
0
A: How To append Element In Array

Janak Prajapatiuse array_push(); my working example is below <?php $array = array("1", "2"); array_push($array, "3", "4"); print_r($array); ?> // output will be Array ( [0] => 1 [1] => 2 [2] => 3 [3] => 4 )

in this case append only one value but I want to add 3 value like "EffectiveStatusId":1,
"EffectiveStatus":"abc",
"RecordCount":7
you mean to say you are appending one more array in it ?
Right i want append array like element
then try array_merge(); it is used to merge two array
Thanks For replay @janak but I want to that element that stored prodedure return eg : Status:abc and Status:efc return from detabase then i want to skip that value form hardcode
06:20
not getting my frnd
if($row->EffectiveStatus != 'abc') then i want to push hadrcod value
simple if you arra condition is true then use function array_merge else nothing
if($row->EffectiveStatus == "Todays Delivery")
{
$result[] = array("EffectiveStatusId"=> $row->EffectiveStatusId,
"EffectiveStatus"=>$row->EffectiveStatus,
"RecordCount"=>$row->RecordCount);
}
else
{
$result[] = array("EffectiveStatusId"=>0,
"EffectiveStatus"=>"Todays Delivery",
"RecordCount"=>0);

}
i tryed this but not getting proper resut
becouse i am new in php so i dont know syntex of php
oh k !!

can you upload full code here
sorry that is not possible for me try to understand
but step by step i will explain you is it ok?
i have one storedProcedure that return resutl like :1 Out For Delivery 7
6 In Transit 91
that count not return 0
but i want to add hardcode value of status that not return form storedprocedure
are you getting me?
06:31
$array = array("EffectiveStatusId"=> $row->EffectiveStatusId,
"EffectiveStatus"=>$row->EffectiveStatus,
"RecordCount"=>$row->RecordCount);

if($row->EffectiveStatus == "Todays Delivery")
{
$new_array=array_merge($array,array("EffectiveStatusId"=> $row->EffectiveStatusId,
"EffectiveStatus"=>$row->EffectiveStatus,
"RecordCount"=>$row->RecordCount) );
}
else
{
// nothing
}


try this
ok let me try
it's return me :{"GetInTransitAndDeliveryResponse":{"EffectiveStatusId":6,"EffectiveStatus":"In Transit","RecordCount":91}}
but storedprocedure allrady return 2 elements

last day (14 days later) »