Jump to content

Array sorting


gwolgamott

Recommended Posts

Okay my grasp on arrays just seems whacked lately... I can understand them one day and not another... anyways issue I have is this:

 

$Array_indexed[0] = "Something1";
$Array_indexed[1] = "Something1!sub1!partA";
$Array_indexed[2] = "Something1!sub2"; 
$Array_indexed[3] = "Something2";

 

take that exampled of what I have and I want to sort it in some sort of an array that after I delimit element 2 or 3... somehow make an overall array using multidimensional arrays. This is where I get lost and seem I can't get it to sort and go into something like this:

 

$array_multi[0] = "Something1";
$array_multi[0][0] = "sub1";
$array_multi[0][0][0] = "part A";
$array_multi[0][1]="sub2";
$array_multi[1] = "Something2";

 

Or do I have this all wrong? I have a feeling I'm thinking of this in the wrong way.

Link to comment
Share on other sites

you CAN make multi dimensional arrays, however, you need to specify whether or not it will be an array..

 

2 examples

 

$array = array();

$array[0] = array();

$array[0][0] = "hi";

$array[0][1] = "howdy!";

$array[1] = array();

$array[1][0] = "hello";

$array[1][1] = "omgosh!";

 

example number two:

 

$array = array(array("hi","howdy"),array("hello","omgosh!"));

Link to comment
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.