Re: Array Question

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Well I don't want have to specify $val['ponbr'] == 'TEST1' I want to say if
($val['ponbr'] == repeated value) then $resultArray[$key] = $val;

In other words I want to go through the array matched the values of ponbr
that repeat or are the same so if they match then I put the results in
another array.  Does this make sense? sorry I have difficulties with arrays
still.

thnx for your input

On 3/29/06, M. Sokolewicz <tularis@xxxxxxx> wrote:
>
> cybermalandro cybermalandro wrote:
>
> > So, I have an array that looks like this
> >
> >
> > rray(3) {
> >   [0]=>
> >   array(8) {
> >     ["line"]=>
> >     string(1) "1"
> >     ["ponbr"]=>
> >     string(5) "34474"
> >     ["emt"]=>
> >     string(3) "yes"
> >     ["qty"]=>
> >     string(1) "5"
> >     ["price"]=>
> >     string(2) "19"
> >     ["shipdate"]=>
> >     string(8) "11/06/07"
> >     ["tracking"]=>
> >     string(17) "11111111111111111"
> >     ["approved"]=>
> >     string(4) "true"
> >   }
> >   [1]=>
> >   array(8) {
> >     ["line"]=>
> >     string(1) "1"
> >     ["ponbr"]=>
> >     string(5) "TEST1"
> >     ["emt"]=>
> >     string(3) "yes"
> >     ["qty"]=>
> >     string(1) "5"
> >     ["price"]=>
> >     string(2) "19"
> >     ["shipdate"]=>
> >     string(8) "12/04/06"
> >     ["tracking"]=>
> >     string(9) "123123123"
> >     ["approved"]=>
> >     string(4) "true"
> >   }
> >   [2]=>
> >   array(8) {
> >     ["line"]=>
> >     string(1) "2"
> >     ["ponbr"]=>
> >     string(5) "TEST1"
> >     ["emt"]=>
> >     string(3) "yes"
> >     ["qty"]=>
> >     string(1) "5"
> >     ["price"]=>
> >     string(2) "12"
> >     ["shipdate"]=>
> >     string(8) "12/04/06"
> >     ["tracking"]=>
> >     string(12) "123123123123"
> >     ["approved"]=>
> >     string(4) "true"
> >   }
> > }
> >
> >
> > I want to see if the array["ponbr"]  values matched then pick this array
> and
> > construct another one with the matched arrays so I can get something
> like
> > this
> >
> >   [0]=>
> >   array(8) {
> >     ["line"]=>
> >     string(1) "1"
> >     ["ponbr"]=>
> >     string(5) "TEST1"
> >     ["emt"]=>
> >     string(3) "yes"
> >     ["qty"]=>
> >     string(1) "5"
> >     ["price"]=>
> >     string(2) "19"
> >     ["shipdate"]=>
> >     string(8) "12/04/06"
> >     ["tracking"]=>
> >     string(9) "123123123"
> >     ["approved"]=>
> >     string(4) "true"
> >   }
> >   [1]=>
> >   array(8) {
> >     ["line"]=>
> >     string(1) "2"
> >     ["ponbr"]=>
> >     string(5) "TEST1"
> >     ["emt"]=>
> >     string(3) "yes"
> >     ["qty"]=>
> >     string(1) "5"
> >     ["price"]=>
> >     string(2) "12"
> >     ["shipdate"]=>
> >     string(8) "12/04/06"
> >     ["tracking"]=>
> >     string(12) "123123123123"
> >     ["approved"]=>
> >     string(4) "true"
> >   }
> >
> > What is the best way to do this efficiently?
> >
> > Thanks for your input!
> >
> $resultArray = array();
> foreach($array as $key=>$val) {
>         if($val['ponbr'] === 'TEST1') {
>                 $resultArray[$key] = $val;
>         }
> }
>
> $resultArray will contain the output you specified; pretty quick IMO.
>
> - tul
>

[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux