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.

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.

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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.