Jump to content

How to remove an array from a multidementional array?


unemployment

Recommended Posts

Right now I am adding in some privacy settings and basically I need to say...

 

foreach ($data as $k => $r)
{
         $users_privacy = fetch_user_privacy_settings($data[$k]['id'], array('avatar', 'location', 'city', 'pm'));
         $users_viewer_user_lvl = user_lvl($data[$k]['id']);

         if (show_info($users_viewer_user_lvl, $users_privacy['location']) === false)
         {
                // do your usual stuff
         }
         else
         {
                // unset this array
         }
}

 

Here is how the array looks...

<pre>Array
(
    [0] => Array
        (
            [id] => 4
            [username] => lovebug
            [firstname] => test
            [lastname] => tests
            [accounttype] => 0
            [country] => American Samoa
            [state] => 
            [city] => Lime
            [guestviews] => 53
            [iviews] => 34
            [eviews] => 307
            [gender] => 0
            [avatar] => /assets/img/avatars/users/place.png
        )

)
</pre>

 

Basically I need to remove array 0 dynamically.

Link to comment
Share on other sites

You can use unset for this, but I don't recommend it.  You want to try to implement all of your permission systems in one place (either at the DB level, or at the PHP level in one place.  Makes it much easier later if you are trying to adjust permissions, insteadof having to hunt all over your code.  So perhaps setup permissions to only get the fields you need depending on certain criteria.

Link to comment
Share on other sites

You can use unset for this, but I don't recommend it.  You want to try to implement all of your permission systems in one place (either at the DB level, or at the PHP level in one place.  Makes it much easier later if you are trying to adjust permissions, insteadof having to hunt all over your code.  So perhaps setup permissions to only get the fields you need depending on certain criteria.

 

I see your point. Hmmm that will make things a bit more difficult though.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.