Jump to content

HELP, with array filter


piccavet

Recommended Posts

Hi !

 

I have an 2d array like this:

                    column 1              column 2          column 3

                      $data[0][0]      $data[0][1]    $data[0][2]

$data[0][0]    RDR                  -1.3                0.001

$data[1][0]    RQR                    0.4                0.01

$data[2][0]    DDR                    1                  0.00004

and more...

 

Now i need to filter this data. I only need the rows with column 3 < 0.01 AND column2 > 1 or column 2 < -1 .

I have this, but it doesn't work:

 

$teller = 0;

for($i = 0; $aantal>$i; $i++)

{

if($data[$i][2]<=0.01)

{

 

$p[$teller][0] = $data[$i][0];

$p[$teller][1] = $data[$i][1];

$p[$teller][2] = $data[$i][2];

$teller++;

}

}

$teller2 = 0;

for($i = 0; $teller>$i; $i++)

{

 

if($p[$i][1] < -1 || $p[$i][1] > 1 )

{

#als de p value kleiner is dan 0.01 dan alles kopieren in een nieuwe array

$r[$teller2][0] = $p[$i][0];

$r[$teller2][1] = $p[$i][1];

$r[$teller2][2] = $p[$i][2];

$teller2++;

}

}

 

Can you help me?

Link to comment
https://forums.phpfreaks.com/topic/230683-help-with-array-filter/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.