I want to extract values from an array depending on a value.



Hello,
I want to extract values from an array depending on a value.

Here's a similar model how my array looks like:

$doc = array(
'4fwef'=>array(1, 'title'),
'refge'=>array(1, 'title'),
'rh4we'=>array(1, 'title'),
'XXXXX'=>array(2, 'title'),
'wlrei5'=>array(2, 'title'),
'rywerg'=>array(3, 'title'),
'eqrmyu'=>array(3, 'title'),
'uymsr'=>array(3, 'title'),
'y555UT'=>array(4, 'title'),
'8roXDw'=>array(4, 'title'),
't556yt'=>array(5, 'title'),
'MYaGGQ'=>array(6, 'title'),
'8h458r'=>array(6, 'title'),
'57rghq'=>array(6, 'title'),
'2w7enm'=>array(6, 'title'),
'89qern'=>array(7, 'title'),
'85trnn'=>array(7, 'title'),
'1587nr'=>array(8, 'title'),
'83wrr1'=>array(9, 'title')
);


It's multidimensional array.

if you look at this line:
'4fwef'=>array(1, 'title'),

'4fwef' represents the unique key string. 1, represent a category.
'title', represents a short description.

How do i grab/extract all the $docs with similar categories?

i.e
if category = 7, the documents that i want to extract are:
'89qern'=>array(7, 'title'),
'85trnn'=>array(7, 'title'),

if category = 6, then the extraction should give me:
'MYaGGQ'=>array(6, 'title'),
'8h458r'=>array(6, 'title'),
'57rghq'=>array(6, 'title'),
'2w7enm'=>array(6, 'title'),

and so on....


How do i achieve that using the most efficient and fastest method?

Thanks
Marco
.



Relevant Pages

  • Re: how to return mulitple corresponding values
    ... This will extract the dates in ascending order, oldest to newest, that meet ... I'm leaving out the sheet name so be sure to add it to your formula. ... Array entered**: ... If you're not using dynamic named ranges then I would "dummy down" ...
    (microsoft.public.excel.worksheet.functions)
  • Re: [PHP] Dynamic dropdown lists (select)
    ... First, if I got this correct, you can extract the makes select-element from ... The next thing is writing down a js code, that contains an array of models ... Im thinking maybe AJAX ... im not a fan of this technique on full-blown web browsers, ...
    (php.general)
  • Copying an array slice (Was: Re: Difficulties with passing multi-dimensional arrays)
    ... to extract an arbitrary-size slice from an arbitrary-size 2D array and I ... perhaps compiler optimisations would remove that seeming benefit - I know ...
    (comp.lang.c)
  • Newbie: Array of pointers to strings questions.
    ... What I'm trying to do is extract information from one file and insert ... and the information in each case is extracted as a string. ... the relevant file is read into a temp file, ... but handling the array was a problem. ...
    (comp.lang.c)
  • Re: Help with String/Array manipulation
    ... I have an array with column widths. ... Next I have a string. ... would like to extract the number of characters based on the column- ...
    (perl.beginners)