Programming > PHP + MYSQL
Combining Two Functions
Ttech:
I know this is simple, but my brain is fried. I can't seem to get it to work when I combine them. All that needs to be worked on is the if statments.
--- Code: ---function display_only_widgets($plugins){
if(is_array($plugins)) {
foreach($plugins as $plugin_file => $plugin_data) {
if(stristr($plugin_data['Name'], "Sidebar Widgets")) {
unset($plugins[$plugin_file]);
} elseif((!stristr(strval($plugin_data['Name']), "widget"))) {
unset($plugins[$plugin_file]);
// remove plugin from the array since its not a widget
}
} // End foreach
}
return $plugins;
}
function display_only_plugins($plugins){
if(is_array($plugins)) {
foreach($plugins as $plugin_file => $plugin_data) {
if(strval($plugin_data['Name']) == "Sidebar Widgets") {
} elseif(stristr($plugin_data['Name'], "widget")) {
unset($plugins[$plugin_file]);
// remove plugin from the array since its a widget
}
} // End foreach
}
return $plugins;
}
--- End code ---
Ttech:
I may try this later though.
GaMerZ:
hmmm
--- Code: ---function display_only_plugins_widgets($plugins){
if(is_array($plugins)) {
foreach($plugins as $plugin_file => $plugin_data) {
if(stristr($plugin_data['Name'], "Sidebar Widgets")) {
unset($plugins[$plugin_file]);
} elseif((!stristr(strval($plugin_data['Name']), "widget")) && stristr($plugin_data['Name'], "widget")) {
unset($plugins[$plugin_file]);
// remove plugin from the array since its not a widget
}
} // End foreach
}
return $plugins;
}
--- End code ---
Ttech:
Thanks... Let me try it. :)
Ttech:
You gave me an idea!
I think I solved it:
--- Code: ---function display_only_widgets($plugins, $remove_widgets){
if(is_array($plugins)) {
foreach($plugins as $plugin_file => $plugin_data) {
if($remove_widgets === FALSE) {
if(((!stristr(strval($plugin_data['Name']), "widget"))
OR stristr($plugin_data['Name'], "Sidebar Widgets")) {
unset($plugins[$plugin_file]);
}
} else {
if(stristr(strval($plugin_data['Name']), "widget")
OR (!stristr($plugin_data['Name'], "Sidebar Widgets"))) {
unset($plugins[$plugin_file]);
}
}
} // End foreach
}
return $plugins;
}
--- End code ---
Navigation
[0] Message Index
[#] Next page
Go to full version