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

  • SEARCH
  • Home
  • 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 4061982
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T15:32:27+00:00 2026-05-20T15:32:27+00:00

I need to enconde just the first column of an array with n rows,

  • 0

I need to enconde just the first column of an array with n rows,

Array
 (
[0] => Array
    (
        [FamilyName] => Dikkartan, Bartu
        [Balance] => -2446.91
        [Mobile] => 0444497
        [HAddress] => 2/6 Tramsway Street
        [HSuburb] => Rosebery
        [HState] => NSW
        [HPCode] => 

    )

[1] => Array
    (
        [FamilyName] => King, Alan & Luka
        [Balance] => -1676
        [Mobile] => 0433 6090
        [HAddress] => 46/12 Hayberry Street
        [HSuburb] => Crows Nest
        [HState] => NSW
        [HPCode] => 

    ) ...

so I need to make an array just with the first value [familyName],
– I want to have this to use with a jquery autocomplete, so after having the name selected from autocomplete, I use this name to search again in the complete array and fill some textfields with the data from the array

  • I need to search in the array as data is taken from sql, but I cannot search in the db, just use the array data,

  • Is this a good path or what other path should I take to do some autocomplete for the name and then have my textfields filled with the data from that array

thanks a lot!

  • 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-20T15:32:28+00:00Added an answer on May 20, 2026 at 3:32 pm

    Using array_map you can reduce the array to just that element.

    $familyNames = array_map(function($object) {
        return $object['FamilyName'];
    }, $objects);
    
    json_encode($familyNames);
    

    This uses an anonymous function available in php 5.3 otherwise you need to use create_function or a reference to an existing function you’ve created. See the PHP callback documentation.

    create_function('$object', 'return $object["FamilyName"];')
    

    Alternatively you could use a simple foreach loop:

    $familyNames = array();
    foreach($objects as $object)
        $familyNames[] = $object['FamilyName'];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

So I need to encode an array in PHP and store it in plain
I've just deployed my first ASP.NET MVC 2 site, and all appears to be
I need to URL encode just the directory path and file name of a
I need to URL encode a non-latin string (japanese, chinese, or just non ascii
I am pretty new to jQuery, so I need some help here: I just
I need to encode a 100KB+ string as base64 in VBA. Are there any
I need to encode/decode UTF-16 byte arrays to and from java.lang.String . The byte
I need to encode streams of 8 byte such that encoded stream has only
If I have the xml/html data to post we need to encode the data
I need to access the crypto functions of OpenSSL to encode Blowfish data in

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.