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 3601984
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T20:41:20+00:00 2026-05-18T20:41:20+00:00

I am using code igniter to retrieve data from a database What is returned

  • 0

I am using code igniter to retrieve data from a database

What is returned is an array objects

something like

array(
  [0] = {
    mobile => '027xxxxxx',
    id     => 1
  },
  [1] = {
    mobile => '027xxxxxx',
    id     => 4
  },
  [2] = {
    mobile => '027xxxxxx',
    id     => 5
  },
  [3] = {
    mobile => '027xxxxxx',
    id     => 7
  },
  [4] = {
    mobile => '027xxxxxx',
    id     => 9
  },
  [5] = {
    mobile => '027xxxxxx',
    id     => 10
  },
  [6] = {
    mobile => '027xxxxxx',
    id     => 112
  },
  [7] = {
    mobile => '027xxxxxx',
    id     => 113
  }
)

I have a variable called count, this contains an arbitrary number (although always less than the number of objects in the array).

My question is:

Say count = 3,
How would I get an array of 3 random id’s from the object?

something like array(4, 9, 1)

I only want to get a single id once

so array(4, 4, 9) would be incorrect.

Note that the id’s are not linear.

  • 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-18T20:41:21+00:00Added an answer on May 18, 2026 at 8:41 pm
    $random_keys = array_rand(array_keys($your_array), 3);
    

    array_rand

    explain –

    • array_keys only return the key from the original array
    • array_rand will then pick randomly without repeatability
    • and the return of array is contains key to your original array
    • so you can retrieve any information from original array
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using code igniter to retrieve data from a database What is returned
How can I retrieve data from the database by querying records between two dates
Using the code below, I am returning an nvarchar field from MS SQL 2005
I am using code-igniter, and some of my views require jquery. Because they must
EDIT: I am using Code Igniter: www.codeigniter.com So I'm new to web developement and
I am using code igniter. What I want to do is, if a page
I'm using code that I found on the CodeProject.com for a low-level keyboard hook
I've recently started using code coverage tools (particularily Emma and EclEmma), and I really
I have been using code similar to this MessageDlg('', mtWarning, [mbOK], 0); throughout my
I'm using code that takes a bitmap and converts it to 24 BPP so

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.