Page 1 of 3 123 Last
  • Jump to page:
    #1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2003
    Posts
    377
    Rep Power
    76

    Help with characters in array


    I have this code I am working with that sends XML to an API the format has to be just right for it to work. The only part that I can't get it the lineitems.

    It wants to render them as 'name' => 'Some Widget'
    instead of 'name' => 'Some Widget'

    I need to render the &gt as a >
    PHP Code:
       $i 1;
            foreach(
    $Order->Cart->contents as $Item) {
                
    $lineItems[] = array (
                   
    'itemId' => $i++,
                
    'name' => $Item->name,
                
    'quantity' => $Item->quantity,
                
    'unitPrice' => number_format($Item->unitprice,$this->precision,'.','')//format to 1.00
        
    );
        



     
    $whatIWant '\'lineItems\' = ' var_export($lineItems1) ;
        
      

        
    $xml = new AuthnetXML(AUTHNET_LOGINAUTHNET_TRANSKEYAuthnetXML::USE_DEVELOPMENT_SERVER);
        
    $xml->createCustomerProfileTransactionRequest(array(
            
    'transaction' => array(
                
    'profileTransAuthCapture' => array(
                    
    'amount' => $Order->Cart->Totals->total
               
    ),
            
             
    $whatIWant //line items appear here
              
               
    ),
                    
    'customerProfileId' => '135',
                    
    'customerPaymentProfileId' => '186',
                    
    'customerShippingAddressId' => '120',
                    
    'order' => array(
                        
    'invoiceNumber' => 'IN3',
                        
    'description' => 'description of transaction',
                        
    'purchaseOrderNumber' => 'PO3'
                    
    ),
                    
    'taxExempt' => 'false',
                    
    'recurringBilling' => 'false',
                    
    'cardCode' => '000'
                    
    )
                
          
        
          
        );    
       
            
        echo 
    $xml->messages->resultCode;
        echo 
    $xml->messages->message->code;
        echo 
    $xml
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Loyal (3000 - 3499 posts)

    Join Date
    Jul 2003
    Posts
    3,332
    Rep Power
    594
    Where are you generating that?
    There are 10 kinds of people in the world. Those that understand binary and those that don't.
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2003
    Posts
    377
    Rep Power
    76
    Originally Posted by gw1500se
    Where are you generating that?
    About halfway down where it says $whatIWant
    is where I generate the list items.
  6. #4
  7. No Profile Picture
    Contributing User
    Devshed Loyal (3000 - 3499 posts)

    Join Date
    Jul 2003
    Posts
    3,332
    Rep Power
    594
    I mean where are you generating the &gt or >?
    There are 10 kinds of people in the world. Those that understand binary and those that don't.
  8. #5
  9. Sarcky
    Devshed Supreme Being (6500+ posts)

    Join Date
    Oct 2006
    Location
    Pennsylvania, USA
    Posts
    10,846
    Rep Power
    6351
    wrap htmlentities around your var_export
    HEY! YOU! Read the New User Guide and Forum Rules

    "They that can give up essential liberty to obtain a little temporary safety deserve neither liberty nor safety." -Benjamin Franklin

    "The greatest tragedy of this changing society is that people who never knew what it was like before will simply assume that this is the way things are supposed to be." -2600 Magazine, Fall 2002

    Think we're being rude? Maybe you asked a bad question or you're a Help Vampire. Trying to argue intelligently? Please read this.
  10. #6
  11. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2003
    Posts
    377
    Rep Power
    76
    Originally Posted by gw1500se
    I mean where are you generating the &gt or >?
    When that whole page gets called from my shopping cart, it generates a XML request and response. It prints something like this. But the > are not outputted right.

    PHP Code:
        

    <?xml version="1.0"?>
    <createCustomerProfileTransactionRequest>
      <merchantAuthentication>
        <name>xxxxx</name>
        <transactionKey>xxxx</transactionKey>
      </merchantAuthentication>
      <transaction>'lineItems' = array (
      0 =&gt; 
      array (
        'itemId' =&gt; 1,
        'name' =&gt; 'some widget',
        'quantity' =&gt; '3',
        'unitPrice' =&gt; '1.00',
      ),
    )</transaction>
      <customerProfileId>129</customerProfileId>
      <customerPaymentProfileId>119</customerPaymentProfileId>
      <customerShippingAddressId>120</customerShippingAddressId>
      <order>
        <invoiceNumber>INV0</invoiceNumber>
        <description>description of transaction</description>
        <purchaseOrderNumber>P0003</purchaseOrderNumber>
      </order>
      <taxExempt>false</taxExempt>
      <recurringBilling>false</recurringBilling>
      <cardCode>000</cardCode>
    </createCustomerProfileTransactionRequest>
  12. #7
  13. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2003
    Posts
    377
    Rep Power
    76
    Originally Posted by ManiacDan
    wrap htmlentities around your var_export
    This line?

    PHP Code:
    $whatIWant '\'lineItems\' = ' htmlentities(var_export($lineItems1)) ; 
    And now I get =&amp;gt;
    equals sign ampersand amp ; gt ;
    Last edited by mallen; March 13th, 2013 at 01:13 PM.
  14. #8
  15. Sarcky
    Devshed Supreme Being (6500+ posts)

    Join Date
    Oct 2006
    Location
    Pennsylvania, USA
    Posts
    10,846
    Rep Power
    6351
    PHP Code:
     $whatIWant '\'lineItems\' = ' htmlentities(var_export($lineItems1)) ; 
    HEY! YOU! Read the New User Guide and Forum Rules

    "They that can give up essential liberty to obtain a little temporary safety deserve neither liberty nor safety." -Benjamin Franklin

    "The greatest tragedy of this changing society is that people who never knew what it was like before will simply assume that this is the way things are supposed to be." -2600 Magazine, Fall 2002

    Think we're being rude? Maybe you asked a bad question or you're a Help Vampire. Trying to argue intelligently? Please read this.
  16. #9
  17. No Profile Picture
    Contributing User
    Devshed Loyal (3000 - 3499 posts)

    Join Date
    Jul 2003
    Posts
    3,332
    Rep Power
    594
    PHP Code:
    $whatIWant '\'lineItems\' = ' htmlentities(var_export($lineItems1)) ; 
    There are 10 kinds of people in the world. Those that understand binary and those that don't.
  18. #10
  19. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2003
    Posts
    377
    Rep Power
    76
    Originally Posted by gw1500se
    PHP Code:
    $whatIWant '\'lineItems\' = ' htmlentities(var_export($lineItems1)) ; 
    I replied before you last post. See post#7
  20. #11
  21. Sarcky
    Devshed Supreme Being (6500+ posts)

    Join Date
    Oct 2006
    Location
    Pennsylvania, USA
    Posts
    10,846
    Rep Power
    6351
    Ok, so what is the problem then? Isn't that what you wanted? The forum unfortunately automatically converts these HTML entities for you, so your code example at the beginning was identical.
    HEY! YOU! Read the New User Guide and Forum Rules

    "They that can give up essential liberty to obtain a little temporary safety deserve neither liberty nor safety." -Benjamin Franklin

    "The greatest tragedy of this changing society is that people who never knew what it was like before will simply assume that this is the way things are supposed to be." -2600 Magazine, Fall 2002

    Think we're being rude? Maybe you asked a bad question or you're a Help Vampire. Trying to argue intelligently? Please read this.
  22. #12
  23. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2003
    Posts
    377
    Rep Power
    76
    Originally Posted by ManiacDan
    Ok, so what is the problem then? Isn't that what you wanted? The forum unfortunately automatically converts these HTML entities for you, so your code example at the beginning was identical.
    I can't post it becuase it converts it back in this post. Im getting this as a result

    equals sign ampersand amp ; gt ;
  24. #13
  25. No Profile Picture
    Contributing User
    Devshed Loyal (3000 - 3499 posts)

    Join Date
    Jul 2003
    Posts
    3,332
    Rep Power
    594
    I believe the OP wants the actual character not the HTML code for it.
    There are 10 kinds of people in the world. Those that understand binary and those that don't.
  26. #14
  27. Sarcky
    Devshed Supreme Being (6500+ posts)

    Join Date
    Oct 2006
    Location
    Pennsylvania, USA
    Posts
    10,846
    Rep Power
    6351
    Describe the problem. What do you have? What do you want it to be? Where does it come from? You keep saying "I'm getting this." Yes, we know. How, when, why, and is that correct?
    HEY! YOU! Read the New User Guide and Forum Rules

    "They that can give up essential liberty to obtain a little temporary safety deserve neither liberty nor safety." -Benjamin Franklin

    "The greatest tragedy of this changing society is that people who never knew what it was like before will simply assume that this is the way things are supposed to be." -2600 Magazine, Fall 2002

    Think we're being rude? Maybe you asked a bad question or you're a Help Vampire. Trying to argue intelligently? Please read this.
  28. #15
  29. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2003
    Posts
    377
    Rep Power
    76
    I can't type it becuase the forum converts it to the symbol I need.
    PHP Code:

    <transaction>'lineItems' = array (
      
    => array (
        
    'itemId' => '1',
        
    'name' => 'Some Widget',
        
    'quantity' => '1',
        
    'unitPrice' => '1',
      ), 
    See this code. Each part of the array has a equals sign and a greater than symbol. Like it should. But my code generates the html character for that and the Authorize.net API won't accept it in that format. It would say for example 'name' ampersand gt; '1';

    PHP Code:
    foreach($Order->Cart->contents as $Item) {
                
    $lineItems[] = array (
                   
    'itemId' => $i++,
                
    'name' => $Item->name,
                
    'quantity' => $Item->quantity,
                
    'unitPrice' => number_format($Item->unitprice,$this->precision,'.','')//format to 1.00
        
    );
        



     
    $whatIWant '\'lineItems\' = ' var_export($lineItems1) ; 
    Last edited by mallen; March 13th, 2013 at 01:35 PM.
Page 1 of 3 123 Last
  • Jump to page:

IMN logo majestic logo threadwatch logo seochat tools logo