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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T20:41:04+00:00 2026-06-04T20:41:04+00:00

Hi I have the following array array(4) { [0]=> array(3) { [id_acreditado]=> string(3) 174

  • 0

Hi I have the following array

array(4) {
  [0]=>
  array(3) {
    ["id_acreditado"]=>
    string(3) "174"
    ["cantidad"]=>
    string(7) "4008.00"
    ["acreditado"]=>
    string(27) "Olga Olivia Lucio Hernandez"
  }
  [1]=>
  array(3) {
    ["id_acreditado"]=>
    string(3) "175"
    ["cantidad"]=>
    string(7) "4008.00"
    ["acreditado"]=>
    string(23) "Enrique Carranco Vences"
  }
  [2]=>
  array(3) {
    ["id_acreditado"]=>
    string(3) "176"
    ["cantidad"]=>
    string(7) "4008.00"
    ["acreditado"]=>
    string(32) "Juana Patricia Contreras Paredes"
  }
  [3]=>
  array(3) {
    ["id_acreditado"]=>
    string(3) "177"
    ["cantidad"]=>
    string(7) "4008.00"
    ["acreditado"]=>
    string(17) "Noemi Cruz Campos"
  }
}

And I want to create a bidimensional array with some values of the above array and different indices. I’m using a foreach loop to achive that.

$j=1;
foreach($acreditados as $acreditado){
    $tmp['oneCol'] = $j;
    $tmp['twoCol'] = $acreditado['acreditado'];
    $tmp['threeCol'] = $acreditado['cantidad'];
    $info['fourCol'] =$acreditado['id_acreditado'];
    $info[]=$tmp;
    $j++;
}

$tmp is an auxiliar one dimension array that lately is added as a row for bidemensional $info array, however I’m not getting the output expected. I want something like the following as output:

array(4) {
      [0]=>
      array(3) {
        ["oneCol"]=>
        int(1)
["twoCol"]=>
        string(27) "Olga Olivia Lucio Hernandez"
        ["threeCol"]=>
        string(7) "4008.00"
["fourCol"]=>
        string(3) "174" 
      }
      [1]=>
      array(3) {
 ["oneCol"]=>
        int(2)
["twoCol"]=>
        string(23) "Enrique Carranco Vences"
        ["threeCol"]=>
        string(7) "4008.00"
["fourCol"]=>
        string(3) "175"
      }
      [2]=>
      array(3) {
 ["oneCol"]=>
        int(3)
       ["twoCol"]=>
        string(32) "Juana Patricia Contreras Paredes"
        ["threeCol"]=>
        string(7) "4008.00"   
 ["fourCol"]=>
        string(3) "176"
      }
      [3]=>
      array(3) {
 ["oneCol"]=>
        int(4)
       ["twoCol"]=>
        string(17) "Noemi Cruz Campos"
        ["threeCol"]=>
        string(7) "4008.00"
 ["fourcol"]=>
        string(3) "177"
      }
    }
  • 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-04T20:41:05+00:00Added an answer on June 4, 2026 at 8:41 pm

    You have a code error

    The line

    $info['fourCol'] =$acreditado['id_acreditado'];
    

    Should be

    $tmp['fourCol'] =$acreditado['id_acreditado'];
    

    So the code show be: (With the added $tmp array reset)

    $j=1;
    foreach($acreditados as $acreditado){
        $tmp = array();
        $tmp['oneCol'] = $j;
        $tmp['twoCol'] = $acreditado['acreditado'];
        $tmp['threeCol'] = $acreditado['cantidad'];
        $tmp['fourCol'] =$acreditado['id_acreditado'];
        $info[] = $tmp;
        $j++;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following array structure: Array ( [0] => Array ( [configuration_id] =>
I have the following array. <cfset ItemHasUsers = arrayNew(1)> <cfloop query=qReadData> <cfset ItemHasUsers[qReadData.currentrow][ID] =
I have following array, that I need to operate by hand on bitmaps. const
I have the following array, $myarray[0]['first_name'] $myarray[0]['last_name'] I want to turn it into: $myarray['first_name']
I have the following array as3 example: var arrayDefinitionsargsAmfPhp:Array = new Array(); arrayDefinitionsargsAmfPhp['tabela'] =
I have the following array: a = [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16] I use it for some visual
I have the following array, I need to reorder it by average rating descending.
I have the following array: Array( [0] => 0,0 [1] => 0,1 [2] =>
I have the following array ::: WC_Cart Object ( [cart_contents] => Array ( [d6f5bb0bbc]
I have the following array response from a server to an android app. [

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.