6 Replies Latest reply on Feb 13, 2013 9:34 AM by Flex harUI

    URLVariables send parameter as array

    flashharry! Level 1

      Hi,

       

      I need to send an array of data with URLVariables so that when its received by the php script it see them as an array.

       

       

      var SEARCHFIELD:Array = new Array();

      SEARCHFIELD.push([{PATHTYPE:1,PATHTYPELOGIC:0}]);

       

      var params:URLVariables = new URLVariables();

      var search_volume:Array = new Array();

      search_volume.push('/Volumes/Customers/Stock_Pictures');

      search_volume.push('/Volumes/Customers/mercedes');

       

      params.search_volume = search_volume;

      params.SEARCHFIELD = SEARCHFIELD;

      searchData.data = params;

       

      Gives me this in php

      Array
      (
          
          [search_volume] => /Volumes/Customers/Stock_Pictures,/Volumes/Customers/mercedes
          [SEARCHFIELD] => [object Object] 
      )

       

      What I want is this in php.

       

      Array
      (
          [search_volume] => Array
              (
                  [0] => /Volumes/Customers/mercedes
                  [1] => /Volumes/Customers/Stock_Pictures
              )
      
          
          [SEARCHFIELD] => Array
              (
                  [0] => Array
                      (
                          [PATHTYPE] => 1
                          [PATHTYPELOGIC] => 0
                      )
      
              )
      )
      Thanks in advance
      Flash

        • 1. Re: URLVariables send parameter as array
          Madhav Subedi Level 4

          if possible, use AMFPHP; it will make your job quite easier.

          • 2. Re: URLVariables send parameter as array
            flashharry! Level 1

            Normally I use JASON and http service, the issue with this is that I do not have any access to the PHP source code. The php code is not mine and is encoded. I know what I need to send to the php script, API if you will. I don't need to even process the results, need to post the data then let the PHP take over.

             

            I need to do a lot of user data gathering and business logic, then post this data and show the results via the PHP. I just need to be able to pass an array of data to the php script.

             

            in javascript you would just use literals examplename[0].name = xx, I want to do the same with URLVariables....

             

            TIA

            flash

            • 3. Re: URLVariables send parameter as array
              flashharry! Level 1

              ok I figured out first part and got a array to go across

               

              var params:URLVariables = new URLVariables();

              var search_volume:Array = new Array();

              search_volume.push('/Volumes/Customers/Stock_Pictures');

              search_volume.push('/Volumes/Customers/mercedes');

               

              //this is the bit that works as an array using [] in the quoted name

              params["search_volume[]"] = search_volume;

               

              this gives me......

               

               [search_volume] => Array
                      (
                          [0] => /Volumes/Customers/Stock_Pictures
                          [1] => /Volumes/Customers/mercedes
                      )
              
              in the php post data
              
              I now need to figure out nested (multidimensional) arrays
              
              any ideas?
              
              flash

              • 4. Re: URLVariables send parameter as array
                flashharry! Level 1

                ok figured it out

                 

                var params:URLVariables = new URLVariables();

                var search_volume:Array = new Array();

                search_volume.push('/Volumes/Customers/Stock_Pictures');

                search_volume.push('/Volumes/Customers/mercedes');

                 

                params["SEARCHFIELD[0][PATHTYPELOGIC]"] = "0"

                params["SEARCHFIELD[0][PATHTYPE]"] ="1";

                 

                params["search_volume[]"] = search_volume;

                 

                [SEARCHFIELD] => Array
                        (
                            [0] => Array
                                (
                                    [PATHTYPELOGIC] => 0
                                    [PATHTYPE] => 1
                                )
                
                        )
                
                    [search_volume] => Array
                        (
                            [0] => /Volumes/Customers/Stock_Pictures
                            [1] => /Volumes/Customers/mercedes
                        )
                
                Phew the answer was simple, why did it take so long

                • 5. Re: URLVariables send parameter as array
                  jayarjo Level 1

                  For me it sends comma-separated list instead of array.

                   

                  [search_volume] => Array

                          (

                              [0] => /Volumes/Customers/Stock_Pictures, /Volumes/Customers/mercedes

                          )

                   

                  rather than:

                   

                  [search_volume] => Array

                          (

                              [0] => /Volumes/Customers/Stock_Pictures

                              [1] => /Volumes/Customers/mercedes

                          )

                  • 6. Re: URLVariables send parameter as array
                    Flex harUI Adobe Employee

                    What does your code look like?  I think you have to assign each element.