Array Lookup after fetch_all

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Claus Mygind
    Contributor
    • Mar 2008
    • 571

    Array Lookup after fetch_all

    When I use

    $x = $result->fetch_all($res ult = MYSQLI_NUM);

    I get a multidimensiona l array, since each row is an array of columns and then the collection of rows is the outer array.

    My problem is this, I want to scan the inner array's 2nd item for a value so I don't have to loop through the entire result set each time through.

    Sample result set would look something like this

    array(
    array(
    xxxx,
    A
    ),
    array(
    yyyyy,
    B
    ),
    )

    How can I scan for that 2nd value without looping?

    I have tried array_search and array_intersect , but I am not able to construct the code properly.

    Say I wanted to return the content of array that has "B", How would I do that?
  • ariful alam
    New Member
    • Jan 2011
    • 185

    #2
    You can have a look here. http://www.w3schools.com/php/php_arrays.asp

    Comment

    • Claus Mygind
      Contributor
      • Mar 2008
      • 571

      #3
      Yes I have looked at that before, but it is not what I am looking for. I think I will have to loop the query result once and store in an array which I will build.

      Thanks for your help though

      Comment

      Working...