0

i am using mongodb and my query returns only a key value the following is the format of the var_dump

 <pre>array (size=471)
  0 => 
    array (size=1)
      'sno' => string '162230' (length=6)
  1 => 
    array (size=1)
      'sno' => string '165333' (length=6)
  2 => 
    array (size=1)
      'sno' => string '181312' (length=6)
  3 => 
    array (size=1)
      'sno' => string '181313' (length=6)
  4 => 
    array (size=1)
      'sno' => string '181314' (length=6)
  5 => 
    array (size=1)
      'sno' => string '181315' (length=6)
  6 => 
    array (size=1)
      'sno' => string '181316' (length=6)
  7 => 
    array (size=1)
      'sno' => string '181317' (length=6)
  8 => 
    array (size=1)
      'sno' => string '181318' (length=6)
  9 => 
    array (size=1)
      'sno' => string '181319' (length=6)
  10 => 
    array (size=1)
      'sno' => string '181320' (length=6)</pre>

I do not want key . all i want is a array of values without a loop.

1
  • Consider trying with implode(); Commented Jan 27, 2016 at 12:49

1 Answer 1

1

Solved it.

 array_column($arr,"sno")
Sign up to request clarification or add additional context in comments.

1 Comment

Good to note this is PHP doing this not MongoDB which your question would suggest is the wrong approach

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.