Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 597333
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T16:16:08+00:00 2026-05-13T16:16:08+00:00

(Very useful when querying DB). If I have a multy dim array [[‘id’=>1],[‘id’=>2],[‘id’=>34],[‘id’=>67]] and

  • 0

(Very useful when querying DB).
If I have a multy dim array

 [['id'=>1],['id'=>2],['id'=>34],['id'=>67]]

and what I want is [1,2,34,67]

I know how to do it in code, just asking if there is a built in way in PHP (or may be in PDO) to do this.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T16:16:08+00:00Added an answer on May 13, 2026 at 4:16 pm

    I think you need PDO::FETCH_COLUMN mode in fetchAll, which returns only a single column as array:

    <?php
    $sth = $dbh->prepare("SELECT name, colour FROM fruit");
    $sth->execute();
    
    /* Fetch all of the values of the first column */
    $result = $sth->fetchAll(PDO::FETCH_COLUMN, 0);
    var_dump($result);
    ?>
    

    From the manual:

    To return an array consisting of all values of a single column from the result set, specify PDO::FETCH_COLUMN. You can specify which column you want with the column-index parameter.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

List Comprehension is a very useful code mechanism that is found in several languages,
In JavaScript nested functions are very useful: closures, private methods and what have you..
This is something that I think would be very useful. Basically, I'd like there
The code-complete feature in Visual Studio is very useful, and it still works for
I have always found this to be a very useful feature in Visual Studio.
Are there any c++ networking libs that are very useful and robust? and libs
I searched this site and found a very useful snippet of code that i've
I love the JSLint add-in - very useful. Having just upgraded to VS2010, I
I have encountered a situation where it would be very useful to specify a
Several REPLs (like ruby's irb ) have some very useful features, such as using

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.