Re: PHP array problem <ns4:item>

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



I've created an object for each message and then created an array of these
objects. Unfortunately we still get the same problem as the PEAR library
forces an <item> tag if the array key is either blank or numeric.  I'm not
sure whether I understood Mikes suggestion.........

My code snippet is

////////////////////////////////////////////////////////////////////////////
//////////////////////////////////

class messagesubmission {
    var $originator;            // originator mobile number
    var $recipient;             // recipient mobile number
    var $body;                  // text message
    var $type;                  // message type
    var $validityperiod;        // message type

    function messagesubmission ($aa) {
        foreach ($aa as $k=>$v)
            $this->$k = $aa[$k];
    }
}// end of class


    function readMessage() {

    // create message 1
    $message = array('originator' => 'originatorno',
                     'recipient' => 'recipentno',
                     'body' => 'This is a test message 1',
                     'type' => 'Text',
                      'validityperiod' => '10');

    $MyObjectArray[][messagesubmission] = createMessageObject($message);

    // create message 2
   $message = array('originator' => 'originatorno',
                     'recipient' =>  'recipentno',
                     'body' => 'This is a test message 2',
                     'type' => 'Text',
       'validityperiod' => '10');

    $MyObjectArray[][messagesubmission] = createMessageObject($message);

    return $MyObjectArray;
}

function createMessageObject($message) {
    return new messagesubmission($message);
}

$messages = readMessage();

////////////////////////////////////////////////////////////////////////////
//////////////////////////////////

Any help would be very welcome.

Andy E


"Mike Carter" <mikeatwork@ukonline.co.uk> wrote in message
11054A7BC9A71245BCBB991757932573100FE6@mail.koa.uk.com">news:11054A7BC9A71245BCBB991757932573100FE6@mail.koa.uk.com...
>
>
> > -----Original Message-----
> > From: Thomas Ashbee [mailto:thomas@merinet.com]
> > Sent: 25 November 2003 13:06
> > To: soap@lists.php.net
> > Subject:  PHP array problem <ns4:item>
> >
> > How do i stop the <ns4:item> being inserted in to the request
> >
> >
> > $message_array = array(
> >                             array('originator' => 'originatorno',
> >                                   'recipient' => 'recipentno',
> >                                   'body' => 'This is a test message',
> >                                   'type' => 'Text',
> >           'validityperiod' => '10'),
> >             array('originator' => 'originatorno',
> >                                   'recipient' => 'recipentno',
> >                                   'body' => 'This is a test message',
> >                                   'type' => 'Text',
> >           'validityperiod' => '10')
> >           );
> >
> > $secondarray = array('messagesubmission' => $message_array);
> >
>
> Use objects rather than nested arrays to put your attributes in. I use a
> stdClass like:
> $req = new StdClass;
> $req->originator = 'originatorno';
> $req->recipient = 'recipentno';
> Etc...
> Then add this class to the parent class (if your nesting things) before
> submitting it to the webservice.
>
> Regards,
>
>
>
> Mike C.
>
>
> ________________________________________________________________________
> This email has been scanned for all viruses by the MessageLabs Email
> Security System. For more information on a proactive email security
> service working around the clock, around the globe, visit
> http://www.messagelabs.com
> ________________________________________________________________________

-- 
PHP Soap Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [PHP Users]     [Kernel Newbies]     [PHP Database]     [Yosemite]

  Powered by Linux