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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T20:49:00+00:00 2026-05-25T20:49:00+00:00

This is my $data variable: cv = 1,2,3,4,5:::cpt = 4,5 … Now I need

  • 0

This is my $data variable:

cv = 1,2,3,4,5:::cpt = 4,5 …

Now I need some function, where I can add the number as param (number will be $data number value).

for example.

function getPermission($id) {

... return $something;
}

Then if I call the function like: echo getPermission(4); it’ll print out the data ‘keys’ where the 4 will be inside, as a value.

So, to be clear:

if I call the function like this:

echo getPermission(4); output will be “cv” and “cpt”.

but if I call it this way:

echo getPermission(1);

it’ll only output “cv” because number (1) is located in the cv key.

Hope you guys understand, feel free to ask if something aren’t clear enough.

  • 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-25T20:49:01+00:00Added an answer on May 25, 2026 at 8:49 pm
    $str = 'cv = 1,2,3,4,5:::cpt = 4,5';
    $tmp = explode(':::', $str);
    $data = array();
    foreach ($tmp as $arr) {
        $tokens = explode(' = ', $arr);
        $data[$tokens[0]] = explode(',', $tokens[1]);
    }
    
    print_r(getPermission(4, $data));
    print_r(getPermission(1, $data));
    
    function getPermission($id, $data) {
        $out = array();
        foreach ($data as $key => $arr) {
            if (in_array($id, $arr)) $out[] = $key;
        }
        return $out;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to summarize a data frame by some variables, ignoring the others. This
I need to store data that looks like this: <root> <child-one> value 1 value
I have data formatted 2009-07-17T00:00:00-05:00 in varchar variable. How can I convert this data
var data = $(#list2 li).map(function () { return $(this).children().html(); }).get(); the data variable contains
I can set data in JTable constructor, and then user can change this data
Following is the sample data. I need to make 3 copies of this data
I am reading a csv file into a variable data like this: def get_file(start_file):
I have a code similar to this: $.ajax({ success: function(data) { text = '';
I have a function that retrieves some data from the database, formats it as
in my webapp I have a variable like this var data = { getItem:

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.