how do i add an index to and object

I have the following object(below):

object(stdClass)#49 (1) {
["NewOrder"] => object(stdClass)#50 (12) {
["BTN"] => string(10) "XXXXXXXXXXXXXXXxx"
["PreOrderTransactionId"] => string(22) "XXXXXXXX"
["PartnerOrderId"] => string(17) "XXXXXXXXXXX"
["QwestOrderId"] => string(9) "N57395699"
["SalesCode"] => string(7) "XXXXXXXX"
["OrderStatus"] => string(7) "Pending"
["OrderStatusCode"] => string(4) "OPEN"
["OrderStatusSourceSystem"] => string(5) "CPLUS"
["OrderStatusMessage"] => string(0) ""
["OrderStatusDate"] => string(10) "2013-12-09"
["OrderStatusTime"] => string(8) "08:02:30"
["ProductFamily"] => array(3) {
[0] => object(stdClass)#51 (2) {
["ProductFamilyName"] => string(7) "BUNDLE+"
["ProductLines"] => object(stdClass)#52 (3) {
  ["WTN"] => string(10) "3033689919"
  ["AppointmentDate"] => string(10) "2013-12-20"
  ["Products"] => object(stdClass)#53 (5) {
    ["ProductName"] => string(36) "INTERNET 100+ MBPS & HOME PHONE PLUS"
    ["Usoc"] => string(5) "BBBVC"
    ["Quantity"] => string(1) "1"
    ["Action"] => string(1) "I"
    ["Status"] => string(4) "OPEN"
  }
}
}
}
}
}

How can add an index[0] after ["NewOrder"] object to look like this:

object(stdClass)#49 (1) {
["NewOrder"] => array(1) {
[0] => object(stdClass)#50 (12) {

the reason i need to do this is because sometimes the it will only have one Order sometime it will have multiples.If the there is only one it will fail in the for each loop.

Answers


if (!is_array($this->view->Orders->NewOrder)) {
            $this->view->Orders->NewOrder = array($this->view->Orders->NewOrder);
    Zend_Debug::dump($this->view->Orders->NewOrder);
        }   

Need Your Help

What are the number of ways in which my approach to a news-feed is wrong?

php mysql codeigniter news-feed

This question has been asked a THOUSAND times... so it's not unfair if you decide to skip reading/answering it, but I still thought people would like to see and comment on my approach...

Why doesn't HXT's xpath searcher return results for a simple query?

haskell xpath hxt

In http://www.xpathtester.com/xpath i tested that //i in should work. Why doesn't it?

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.