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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T05:37:13+00:00 2026-06-12T05:37:13+00:00

I have an array inside another and I would like to change a value

  • 0

I have an array inside another and I would like to change a value in a key.

        //Obtenemos el numero de arrays
        $count = array();
        for($i = 0; $i < count($passer); $i++)
        {   
              if(array_key_exists($passer[1],$passer[$i])) {
              $passer[1] = "hola";
              }
             $count[] = $passer[$i];  
        }
        //return....
        return $count;

I need to change entries where the key is 1 and replace the value.
I have this array output:

array
(
     [0]=>array
          (
          [0]=>81278
          [1]=>87364
          [2]=>34923
          )
     [1]=>array
          (
          [0]=>81278
          [1]=>87364
          [2]=>34923
          )
)

but I get an error:

Warning: array_key_exists() [function.array-key-exists]:

Any idea what this means and what to do about it?

  • 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-06-12T05:37:14+00:00Added an answer on June 12, 2026 at 5:37 am

    Several things you should change. First of all the way you write your for statement isn’t optimal, it will execute the count() function upon every iteration, make it like so

    for($i = 0, $c = count($passer); $i < $c; $i++)
    

    Second, your problem. You need to check the key, which in your case is static 1, in the array $passer[$i], so your array_key_exists() function should look like this

    array_key_exists(1,$passer[$i])
    

    array_key_exists expects the first parameter to be the key and second the array you wish to inspect

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

Sidebar

Related Questions

I have a struct that's inside an array that is nested inside another struct,
Possible Duplicate: one variable row inside another variable row I have script something like
I would like to know how to replace , characters inside array brackets []
I have an array set inside a velocity template that contains some paths. The
I have a struct with a dynamic array inside of it: struct mystruct {
I have a question in initializing my structure array inside a structure array. for
I have a Matlab function that creates a cell array with matrixes inside. It
i have a plist that's at its root an array with dictonaries inside it.
i want to have a foreach loop where the initial array is changed inside
I have array of select tag. <select id='uniqueID' name=status> <option value=1>Present</option> <option value=2>Absent</option> </select>

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.