I have an array filled with objects but I'm having a lot of difficulty getting the properties of the objects. I need to access individual properties.
Here is the var_dump():
array (size=1)
0 =>
object(stdClass)[13]
public 'CustShipToID' => string '0' (length=1)
public 'CustDesc' => null
public 'Address1' => null
public 'Address2' => null
public 'City' => null
public 'Phone' => null
public 'State' => null
public 'ZIP' => null
public 'ArrivalDate' => string '2014-10-19 00:00:00' (length=19)
public 'LoadDate' => string '2014-10-17 00:00:00' (length=19)
public 'StopNum' => string '2' (length=1)
public 'ConfNum' => string '5143372' (length=7)
public 'EVNum' => string '4409' (length=4)
public 'ApptNum' => string '5pm' (length=3)
public 'CarrId' => string '249' (length=3)
public 'Temperature' => string '34' (length=2)
public 'CarrDesc' => string 'JOHNY RAY TEST' (length=14)
public 'LoadID' => string '1151' (length=4)
public 'CustPOID' => string '4771' (length=4)
public 'POBillToRef' => string '74312' (length=5)
public 'POShipToRef' => string '' (length=0)
array (size=1)
0 =>
object(stdClass)[14]
public 'CustShipToID' => string '240' (length=3)
public 'CustDesc' => string 'AMERICOLD, TAUNTON ' (length=30)
public 'Address1' => string '455 JOHN HANCOCK RD ' (length=30)
public 'Address2' => string ' ' (length=22)
public 'City' => string 'TAUNTON' (length=7)
public 'Phone' => string '508-513-4409' (length=12)
public 'State' => string 'MA' (length=2)
public 'ZIP' => string '02780' (length=5)
public 'ArrivalDate' => string '2014-10-19 00:00:00' (length=19)
public 'LoadDate' => string '2014-10-17 00:00:00' (length=19)
public 'StopNum' => string '1' (length=1)
public 'ConfNum' => string '' (length=0)
public 'EVNum' => string '4409' (length=4)
public 'ApptNum' => string '7am' (length=3)
public 'CarrId' => string '249' (length=3)
public 'Temperature' => string '34' (length=2)
public 'CarrDesc' => string 'JOHNY RAY TEST' (length=14)
public 'LoadID' => string '1151' (length=4)
public 'CustPOID' => string '5176' (length=4)
public 'POBillToRef' => string '51424' (length=5)
public 'POShipToRef' => string '' (length=0)
Here is how I build my array:
$arr=array();
for($i=0; ($i<count($custpo_ids)-1); $i++)
{
//echo $i." ".$custpo_ids[$i];
$arr[] = array($report_model->getBOLCustomerInfoII($custpo_ids[$i]));
}
Here is my code to process the array:
for($y = 0; $y < count($arr); $y++){
foreach($arr[$y] as $val){
//example property get
$val->EVNum;
}
}
Thoughts? The var dump is the right data, but somehow I'm trying to access it improperly.
var_dumpon$valand see what you get. Also what is the exact error you are getting?$report_model->getBOLCustomerInfoII($custpo_ids[$i])? Is it another array? If it is another array, then it is a 3 dimensional array, and you are only going through 2 dimensions. So you would need to place another loop in your foreach statement to get the objectarray($report_model->getBOLCustomerInfoII($custpo_ids[$i]))to$report_model->getBOLCustomerInfoII($custpo_ids[$i]). Reason: It would only be 2 demintions. Since the pointer returns an array anyways, putting it into another array is kinda pointless, in my opinion. Alsoforeachloops would be a better, easier way to get them.