unemployment Posted July 29, 2011 Share Posted July 29, 2011 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. Quote Link to comment https://forums.phpfreaks.com/topic/243208-how-to-remove-an-array-from-a-multidementional-array/ Share on other sites More sharing options...
trq Posted July 29, 2011 Share Posted July 29, 2011 unset. Quote Link to comment https://forums.phpfreaks.com/topic/243208-how-to-remove-an-array-from-a-multidementional-array/#findComment-1249228 Share on other sites More sharing options...
Ninjakreborn Posted July 30, 2011 Share Posted July 30, 2011 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. Quote Link to comment https://forums.phpfreaks.com/topic/243208-how-to-remove-an-array-from-a-multidementional-array/#findComment-1249459 Share on other sites More sharing options...
unemployment Posted July 31, 2011 Author Share Posted July 31, 2011 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. Quote Link to comment https://forums.phpfreaks.com/topic/243208-how-to-remove-an-array-from-a-multidementional-array/#findComment-1249641 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.