[eluser]BrianDHall[/eluser]
Just ran into this today, and wondering if there is anything 'wrong' with my solution.
Consider this:
Code:
if ($real_array[$potential_element])
{
// do something
}
The problem - if $potential_element is not a valid index of the array, it'll throw a PHP notice. I don't want to do that, so normally I'd wrap it in a call to isset() or !empty(), etc.
But is there anything wrong with just doing this:
Code:
if (@$real_array[$potential_element])
{
// do something
}
??? Just a simple @ to shut PHP up, explicitly stating that "I know this might not be initialized - I understand, and I don't care".
This seems such a simpler and more readable solution to wrapping up something so simple in an unnecessary function call.
So, is ok (it works without error on my machines), or is there something I'm missing?