Modifying a 3-D Array<

liunx

Guest
I'm using a 3-D array to store a bunch of data and I'm looking for a quick way to delete a record from the middle of the array and subsequently have all of the other records shift up. So, for instance if I have

$record[0][0]=1
$record[0][1]=2
$record[0][2]=3

$record[1][0]=4
$record[1][1]=5
$record[1][2]=6

$record[2][0]=7
$record[2][1]=8
$record[2][2]=9

$record[3][0]=10
$record[3][1]=11
$record[3][2]=12

If I want to simply remove record $record[1][X], is there a simple function to call that will accomplish this and shift everything up? I've looked but can't seem to find one.Is that VRML?

Anywho I think a simple "data array function=[#] found" script should work.first of all, if you delete [1][1], how exactly do you want it to shift? Original:$record[0][0]=1
$record[0][1]=2
$record[0][2]=3

$record[1][0]=4
$record[1][1]=5 //to delete
$record[1][2]=6

$record[2][0]=7
$record[2][1]=8
$record[2][2]=9

$record[3][0]=10
$record[3][1]=11
$record[3][2]=12Do you want it to shift like this:$record[0][0]=1
$record[0][1]=2
$record[0][2]=3

$record[1][0]=4
$record[1][1]=8
$record[1][2]=6

$record[2][0]=7
$record[2][1]=11
$record[2][2]=9

$record[3][0]=10
$record[3][1]=
$record[3][2]=12or like this:$record[0][0]=1
$record[0][1]=2
$record[0][2]=3

$record[1][0]=4
$record[1][1]=6
$record[1][2]=7

$record[2][0]=8
$record[2][1]=9
$record[2][2]=10

$record[3][0]=11
$record[3][1]=12
$record[3][2]=Once we know how you want it to shift, it'll help. It's a bit more confusing with a 3D array as opposed to a 2D array, since there is more than 1 way to shift things around.If I want to simply remove record $record[1][X],

In other words, I want to delete everything in the $record[1][X] row, which includes

$record[1][0],
$record[1][1], &
$record[1][2]

What I'm basically doing is scanning the entire array and looking for any value in $record[X][1] that is greater than 3. If I find one, I want to remove that entire row in the array and shift everything back up. So if I had the following record in the array:

$record[1][0]=1
$record[1][1]=4
$record[1][2]=1

since $record[1][1] is greater than 4 I want to remove all 3 and shift everything else up. So

$record[2][0]
$record[2][1]
$record[2][2]

would take its place,

$record[3][0]
$record[3][1]
$record[3][2] would take $record[2][X]'s place, etc.
 
Back
Top