Jump to content

Recommended Posts

Hi all !

is there a difference between an array of arrays as 

rs1 = [
	[1,5,6,7,8,9],
	[ 2,7,6,5,4,3],
  	[3,12,13,14,15,16]
 ];

and another formed as below as

var rs1 = "1,5,6,7,8,9 2,7,6,5,4,3 3,12,13,14,15,16";
rs1 = rs1.split(" ");

//alert(rs1[0]);
//alert(rs1[1]);
//alert(rs1[2]);
//alert(rs1.length);

if so, can someone explain what the difference is.

Thank you !

Link to comment
https://forums.phpfreaks.com/topic/309060-same-arrays-or-not/
Share on other sites

You need to learn the difference between arrays and strings.

The first is an array of arrays, the second is an array of strings containing numbers and commas

Array
(
    [0] => Array
        (
            [0] => 1
            [1] => 5
            [2] => 6
            [3] => 7
            [4] => 8
            [5] => 9
        )

    [1] => Array
        (
            [0] => 2
            [1] => 7
            [2] => 6
            [3] => 5
            [4] => 4
            [5] => 3
        )

    [2] => Array
        (
            [0] => 3
            [1] => 12
            [2] => 13
            [3] => 14
            [4] => 15
            [5] => 16
        )

)
Array
(
    [0] => 1,5,6,7,8,9
    [1] => 2,7,6,5,4,3
    [2] => 3,12,13,14,15,16
)

 

  • Thanks 1
Link to comment
https://forums.phpfreaks.com/topic/309060-same-arrays-or-not/#findComment-1568856
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.