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

  • Home
  • SEARCH
  • 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 6978507
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T17:45:58+00:00 2026-05-27T17:45:58+00:00

i have multidimension array $a = 5,add|4,edit|6,add|6,edit|19,add|19,delete|19,view; then i explode $a $array_a = explode(|,

  • 0

i have multidimension array

$a = "5,add|4,edit|6,add|6,edit|19,add|19,delete|19,view";

then i explode $a

$array_a = explode("|", $a);

//loop

for($i=0;$i<=count($arr_a)-1;$i++){

    arr_b = explode(",", $arr_a[$i]);

    foreach($arr_b as $id => $access){
        echo $id." have access ".$access;
    }
}

//result 
0 have access 5
1 have access add
0 have access 4
1 have access edit
0 have access 6
1 have access add
0 have access 6
1 have access edit
0 have access 19
1 have access add
0 have access 19
1 have access delete
0 have access 19
1 have access view
//-end result

the problem is :

how i can make the result like this

5 have access add
4 have access edit
6 have access add,edit
19 have access add,delete,view

  • 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-27T17:45:58+00:00Added an answer on May 27, 2026 at 5:45 pm

    Try this one (tested):

    // intial data
    $strAccess = "5,add|4,edit|6,add|6,edit|19,add|19,delete|19,view";
    
    // build access array
    $arrayAccess = array();
    
    $tmpList = explode('|', $strAccess);
    
    foreach($tmpList as $access)
    {
      list($idUser, $right) = explode(',', $access);
    
      if (!isset($arrayAccess[$idUser]))
        $arrayAccess[$idUser] = array();
    
      $arrayAccess[$idUser][] = $right;
    }
    
    // print it out
    foreach($arrayAccess as $idUser => $accessList)
      echo $idUser." has access ".implode(",", $accessList)."\n";
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this code to add new elements to a multidimension array: $this->shopcart[] =
I have just made the update/add/delete part for the Closure table way of organizing
i have a multi dimension array with sub array having repeated values of '
I have a multidimensional array. I need to search it for a specific range
I have an multidimensional array that looks like this: Array ( [0] => Array
I have a multidimensional array, and I would have multiple arrays within it. Some
Explanation I have a multidimensional array that is iterated over to created a categorized
I have CSV data loaded into a multidimensional array. In this way each row
I have just noticed that a multidimensional array in C# does not implement IEnumerable<T>
I have a PHP class that stores a complex multidimensional array, and rather than

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.