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

Two dimensional arrays

Expand Messages
  • Pablo Vieira
    Hi, 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. I want
    Message 1 of 6 , May 29 8:56 PM
    • 0 Attachment
      Hi,

      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.

      I want to send a table with rows and columns into an array in Javascript.
      Does anyone have any sample code in PHP?

      Thanks

      Pablo
    • 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 2 of 6 , May 30 4:15 AM
      • 0 Attachment
        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 3 of 6 , May 30 4:23 AM
        • 0 Attachment
          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.