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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T00:53:23+00:00 2026-06-15T00:53:23+00:00

UPDATE: Sorry, I figured it out.. I’m only taking out $value[0], so off cause

  • 0

UPDATE: Sorry, I figured it out.. I’m only taking out $value[0], so off cause its only one result. Need more sleep. Thanks alot. I’m still open for suggestions to a cleaner way to split arrays.

I have an array $tdata with this structure:

Array
(
    [] => Array
    (
        [0] => Array
            (
                [firstName] => test
                [lastName] => test
                [userName] => test@test.com
                [password] => test
                [course] => test
                [role] => test
            )

        [1] => Array
            (
                [firstName] => test
                [lastName] => test
                [userName] => test@test.com
                [password] => test
                [course] => test
                [role] => test
            )

    )

    [delete] => Array
    (
        [0] => Array
            (
                [firstName] => test
                [lastName] => test
                [userName] => test@test.com
                [password] => test
                [course] => test
                [role] => test
            )

    )

    [update] => Array
    (
        [0] => Array
            (
                [firstName] => test
                [lastName] => test
                [userName] => test@test.com
                [password] => test
                [course] => test
                [role] => test
            )

    )

    [outrole] => Array
    (
        [0] => Array
            (
                [firstName] => test
                [lastName] => test
                [userName] => test@test.com
                [password] => test
                [course] => test
                [role] => test
            )

    )

)

I am trying to split it up into smaller arrays. Like this:

foreach ($tdata as $key => $value) {

    if ($key == '') {
       $create[] = $value[0];
    }elseif ($key == 'outrole') {
       $outrole[]  = $value[0];
    }elseif ($key == 'delete') {
       $delete[] = $value[0];
    }elseif ($key == 'update') {
       $update[] = $value[0];
    }else{
     $noaction[] = $value[0];
    }

}

This way the array keeps overwriting itself, I think. print_r($create) or any other of the arrays always returns only 1 result. Can enlighten me and tell me what I am doing wrong?

If there is a better way to do it I would love to hear that as well.

Thanks in advance!

  • 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-15T00:53:24+00:00Added an answer on June 15, 2026 at 12:53 am

    If those keys are always present then you don’t really need a loop:

    $create = $original['create'];
    $outrole = $original['outrole'];
    

    You can add a check if they are set:

    $create = isset($original['create']) ? $original['create'] : array();
    

    This will set it to a blank array if it’s not present.

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

Sidebar

Related Questions

UPDATE Turns out I'm just tired. There isn't any problem here sorry for wasting
EDIT: I'm sorry for making this thread as I've figured out the problem. Here's
**Updated. Sorry to those whose answers no longer make sense. So I figured out
UPDATE: sorry my IE 9 was'nt configured well: it should've been set so that
Sorry for the double post, I will update this question if I can't get
update: I mistyped 2 variables...so embarrassing. thanks everyone for the effort! sorry i find
UPDATE: I've been playing around with this more, and it seems like tmux's clear-history
Under MonoTouch, I'd like to access NSUbiquitousKeyValueStoreDidChangeExternallyNotification (iOS5/iCloud key-value inbound update) notification data: NSUbiquitousKeyValueStoreChangeReasonKey
Sorry to ask a naive question but I'm trying to figure out the best
UPDATE: Sorry, forgot to include some of the code (face-palm). I included it in

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.