我如何从这个数组获得价值?

时间:2014-09-09 10:58:36

标签: php arrays

如何获取此数组中的所有customerId,以便添加到数据库中? 我的var转储如下所示: -

array (size=13)
0 => 
object(__PHP_Incomplete_Class)[1]
  public '__PHP_Incomplete_Class_Name' => string 'ManagedCustomer' (length=15)
  public 'name' => string 'Butchers' (length=10)
  public 'login' => string 'james@gmail.co.uk' (length=22)
  public 'companyName' => null
  public 'customerId' => string '7100866198' (length=10)
  public 'canManageClients' => null
  public 'currencyCode' => null
  public 'dateTimeZone' => null
  public 'testAccount' => null
  public 'descriptiveName' => string 'miketest' (length=8)
1 => 
object(__PHP_Incomplete_Class)[2]
  public '__PHP_Incomplete_Class_Name' => string 'ManagedCustomer' (length=15)
  public 'name' => string 'Vets' (length=5)
  public 'login' => string 'info@gmail.co.uk' (length=30)
  public 'companyName' => null
  public 'customerId' => string '5458013070' (length=10)
  public 'canManageClients' => null
  public 'currencyCode' => null
  public 'dateTimeZone' => null
  public 'testAccount' => null
  public 'descriptiveName' => string 'miketest' (length=8)

尝试了很多东西......

1 个答案:

答案 0 :(得分:0)

如果查看var_dump,您将看到创建的对象数组的类型为__PHP_Incomplete_Class。当PHP尝试创建没有类定义的对象时会发生这种情况。在大多数情况下,可以通过使用标准ManagedCustomer(或任何文件名)语法在脚本顶部包含类require_once('managedcustomer.php');的文件来解决此问题。

如果出于某种原因,您无法加载课程,则需要调查几个黑客:查看Incomplete class object PHPPHP class casting。您还可以使用foreach来访问变量。