title: Sorting multi dimensional arrays with search criteria
body: <p>I am working with FLAT FILE database.</p>
  
  <p>OK. Just to eliminate all the "why not use SQL". i HAVE. This is a personal(learning) project. I like working with text files and want to tinker.</p>
  
  <p>So for 2+ days I've searched google and S.O. and tried many variations of methods presented. However they do not get what I am needing. But I did learn the right question to ask :-)</p>
  
  <p>Now&lt; in SQL you can do it this way (since sql is basically a fancy array)</p>
  
  <pre><code>SELECT * FROM [tablename] WHERE `some_field`='user_input1' ORDER BY `sequence_opt`;
  </code></pre>
  
  <p>I want to do that in a database of over 2000 records. (they have been serialized for ease of storing in a text file)</p>
  
  <p>currently I did this: ($data_lib is 2000+ records with 30 fields each, but retrieved as </p>
  
  <pre><code>$data_lib[1]['a_field_name1']
  $data_lib[2]['a_field_name2']
  $data_lib[3]['a_field_name3']
  $data_lib[4]['a_field_name etc...'])
  
  
   foreach($data_lib as $linenum=&gt;$row)
              $sort[$linenum] = $row['some_field'];
              array_multisort($sort,SORT_DESC,$data_lib);
  </code></pre>
  
  <p>that is equivalent to 
  SELECT * FROM [tablename] ORDER BY `some_field'</p>
  
  <p>Works perfect. What I can't seem to do it get this to "WHERE" bY selecting another field as a criteria. As in the first SELECT example. I can't get the "WHERE" clause to work.</p>
  
  <p>Now one thing I have not looked at, is the original way I am reading the database - do you think the issue is there?
  I have tried usort, but I seem to mess the fields doing it that way and the order is wrong.</p>
  
  <p>This site has been absolutely wonderful with all its info, and my questions are perfectly answered.</p>
  
  <p>thank you in advance!!! </p>