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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T06:59:18+00:00 2026-05-31T06:59:18+00:00

It seems to work, but it feels wrong, I assume it is. Is it

  • 0

It seems to work, but it feels wrong, I assume it is.

Is it wrong?

If so, I currently have an array with keys being mysql database id’s and the values being their values.

Would it be better to have the key being "record_"+$id and then explode()ing the key and getting the id from that?

Or is it ok to set your own array keys, and php will just assume they are assoc array keys, rather than indexes?

Thanks

  • 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-31T06:59:20+00:00Added an answer on May 31, 2026 at 6:59 am

    Some built-in PHP functions (like array_merge / array_multisort) will re-index your array:

    array_merge() If the input arrays have the same string keys, then the later value for that key will overwrite the previous one. If,
    however, the arrays contain numeric keys, the later value will not
    overwrite the original value, but will be appended. Values in the
    input array with numeric keys will be renumbered with incrementing
    keys starting from zero in the result array.


    array_multisort() can be used to sort several arrays at once, or a multi-dimensional array by one or more dimensions. Associative
    (string) keys will be maintained, but numeric keys will be re-indexed.

    I would advise you not to do that, use a proper value instead, or at the very least prefix it with a short _:

    foreach ($array as $key => $value)
    {
        $id = ltrim($key, '_');
    
        // do stuff with the actual $id
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

So this seems pretty basic but I can't get it to work. I have
This seems in my head like it should work but I cant figure out
return false seems to work in the submitHandler but I'm not sure why. function
I am Using WaitforComplete() in watiN but it doesnt seems to work well. As
This evaluation in sql doesn't seems to work properly for some reason but i
I've searched similar topics but no solution seems to work. Is there a way
I tried things like $_ENV['CLIENTNAME'] == 'Console' but that seems to work on only
I'm trying to make a google-chart with transparency, but it seems not to work.
Ok this seems so silly but I'm having some trouble getting this to work.
This seems painfully simple, but I can't work out how to do it: I

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.