(See the best response by Nadrew.)
for(var/mob/M in world)
if(M in oview(5))
else if(!(M in oview(5)))
world << "They aren't there?"

Problem description:
So, I've been looking for a solution to a major feature I'd like to use for my game. I'm looking for a code that allows me to search for something on the players screen or in their oview(), but if the desired object isn't there. I want it to perform another action.

Above, I put what I've been testing.
Best response
var/type/to/something/variable = locate() in oview(5)
// Found
// Not found.

As for the code you posted, you should avoid 'in world' anywhere you can when looping.
for(var/mob/M in oview(src,5))
In response to Nadrew
Thanks for the help!