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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T12:03:21+00:00 2026-06-06T12:03:21+00:00

This is my array and I want to add some elements to make it

  • 0

This is my array and I want to add some elements to make it like 2nd array

1.)

array(7) {
  [0] => array(3) {
    ["name"] => string(9) "airG Chat"
    ["product_id"] => int(2469)
    ["price"] => string(4) "0.00"
  }

  [1] => array(3) {
    ["name"] => string(9) "PingChat!"
    ["product_id"] => int(7620)
    ["price"] => string(4) "0.00"
  }
  [2] => array(3) {
    ["name"] => string(25) "MobiEXPLORE Zagreb County"
    ["product_id"] => int(8455)
    ["price"] => string(4) "0.00"
  }
}

After adding items, it should be like this, I tried using for each function but did not work.
2.)

array(7) {
  [0] => array(3) {
    ["name"] => string(9) "airG Chat"
    ["product_id"] => int(2469)
    ["price"] => string(4) "0.00"
    ["description"] => string(23) "this is the custom test"
    ["brief_description"] => string(23) "this is the custom test"
  }

  [1] => array(3) {
    ["name"] => string(9) "PingChat!"
    ["product_id"] => int(7620)
    ["price"] => string(4) "0.00"
    ["description"] => string(23) "this is the custom test"
    ["brief_description"] => string(23) "this is the custom test"
  }
  [2] => array(3) {
    ["name"] => string(25) "MobiEXPLORE Zagreb County"
    ["product_id"] => int(8455)
    ["price"] => string(4) "0.00"
    ["description"] => string(23) "this is the custom test"
    ["brief_description"] => string(23) "this is the custom test"
  }
}
  • 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-06T12:03:22+00:00Added an answer on June 6, 2026 at 12:03 pm

    Use foreach with reference (&):

    foreach($data as &$datum) {
        $datum["description"] = "this is the custom test";
        $datum["brief_description"] = "this is the custom test";
    }
    

    If you’d prefer not to use & (to avoid this problem), you can do

    foreach($data as $i => $datum) {
        $data[$i]["description"] = "this is the custom test";
        $data[$i]["brief_description"] = "this is the custom test";
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to add all the keys from the dictionary to the array. This
I have this script where I want to add an object to an array
I wrote this n-array tree class. I want to write a method to add
I want to my array, somthing like this: array(userid=>username,1=>ganeshfriends,2=>tester) mysql query something like this:
i want to store Arraylist inside Another List, some thing like this i know
I would like to read data from a plist, add some elements and the
I want to add some string objects in GArray. But when i read the
i have an array and i want to convert this array in comma seprated
i want to convert this array Array ( [2] => Array ( ) [4]
I have to array and I want to merge this two array with a

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.