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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T17:14:42+00:00 2026-05-23T17:14:42+00:00

I have $test = array(); if(isset($ln[8])){ $test[] .= $id[0].’=>’.$ln[14]; } But it puts the

  • 0

I have

$test = array();

if(isset($ln[8])){
    $test[] .= $id[0].'=>'.$ln[14];
}    

But it puts the array like this

array (
           [0]=> 6525 => 120
           [1]=> 6521 => 1243
           [2]=> 5214 => 1674
           [3]=> 6528 => 155
)

whereas I want it to do this

array (
           6525 => 120
           6521 => 1243
           5214 => 1674
           6528 => 155
)

How would I do that.

  • 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-23T17:14:42+00:00Added an answer on May 23, 2026 at 5:14 pm

    What you are doing is adding a string consisting of, e.g., “6525 => 120” to each element in the array. What you really want to do is add the value from $lan[14] (e.g., the integer value 120) to the position $id[0] (e.g., 6525). This is how you do that with regular array syntax:

    $test[$id[0]] = $ln[14];
    

    Note how I treat $id[0] as the key to the $test array. It could have been the integer 6265, a string with value "hello", a variable called $key, a function call, or in this case an element from another array.

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

Sidebar

Related Questions

I have a string like this: TEST.DATA.Data.COR.Point,2;TEST.DATA.Data.COR.Point,5;TEST.DATA.Data.COR.Point,12;TEST.DATA.Data.COR.Point,12;TEST.DATA.Data.COR.WordTOFIND,18 I have a list of array with
I have an array that looks like: $fields = array( f1 => array(test), f2
I've tryed mylyn but i cant find that feature, if anyone have test mantis
I have an array which appears like the one below. I want to slice
If I have this array: $foo[0] = 'bar'; $foo[1] = 'bar bar'; echo $foo[0][1];
i have piece of code that works fine on my local test server but
I have a code like this that extract the country code saved in the
If I have the following, $this->Session->write('ScoreCardCriteria', 'test'); And want to add another item to
I have an array with numerous dimensions, and I want to test for the
I have an array @test . What's the best way to check if each

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.