Loading ...
Sorry, an error occurred while loading the content.
 

Re: [json] Two dimensional arrays

Expand Messages
  • Philip Tellis
    ... php: $foo = array( array(1, 2, 3), array(4, 5, 6), array(7, 8, 9)); print json_encode($foo); javascript: var foo = eval( ( + json + ) );
    Message 1 of 6 , May 30, 2006
      Sometime Today, PV cobbled together some glyphs to say:

      > I'd like to know if there's any "standard" procedure to send back a two
      > dimensional array from a PHP server program to a Javascript client program.

      php:
      $foo = array( array(1, 2, 3), array(4, 5, 6), array(7, 8, 9));
      print json_encode($foo);

      javascript:
      var foo = eval('(' + json + ')');

      alert(foo[0][0]);

      --
      The first time, it's a KLUDGE!
      The second, a trick.
      Later, it's a well-established technique!
      -- Mike Broido, Intermetrics
    • Pablo Vieira
      Oops. Well now all of you know what kind of absolute beginner I am! Thanks Pablo
      Message 2 of 6 , May 30, 2006
        Oops. Well now all of you know what kind of absolute beginner I am!

        Thanks

        Pablo

        > -----Mensaje original-----
        > De: Philip Tellis [mailto:philip.tellis@...]
        > Enviado el: martes, 30 de mayo de 2006 13:16
        > Para: json@yahoogroups.com
        > Asunto: Re: [json] Two dimensional arrays
        >
        > Sometime Today, PV cobbled together some glyphs to say:
        >
        > > I'd like to know if there's any "standard" procedure to send back a two
        > > dimensional array from a PHP server program to a Javascript client
        > program.
        >
        > php:
        > $foo = array( array(1, 2, 3), array(4, 5, 6), array(7, 8, 9));
        > print json_encode($foo);
        >
        > javascript:
        > var foo = eval('(' + json + ')');
        >
        > alert(foo[0][0]);
        >
        > --
        > The first time, it's a KLUDGE!
        > The second, a trick.
        > Later, it's a well-established technique!
        > -- Mike Broido, Intermetrics
        >
        >
        >
        >
        > Yahoo! Groups Links
        >
        >
        >
        >
        >
        >
        >
      Your message has been successfully submitted and would be delivered to recipients shortly.