Jump to content

Check if variable is empty?


gamefreak13

Recommended Posts

I have the below code which checks a text string (which is really a url) for certain occurances. However, I also need to make it check if the string is completely empty. This is being used to transform referer url's in to fancy labels, and if the referer is missing, I need it to say "Referer missing".

 

I know an if/else statement would work, but I'm not sure how to implement that in to a switch/case function... or if there is an easier way?

 

function my_parse($text){
$a = parse_url($text);
parse_str($a['query'],$b);
$b = array_change_key_case($b);
switch ($b['fuseaction']){
	case 'user.viewprofile':
		return 'Profile '.$b['friendid'];
		break;
	case 'bulletin.read':
		return 'Bulletin '.$b['messageid'];
		break;
	case 'mail.readmessage':
		return 'Message '.$b['messageid'];
		break;
	default:
		return 'Unknown Source';
}
print_r($b);
}

Link to comment
https://forums.phpfreaks.com/topic/106888-check-if-variable-is-empty/
Share on other sites

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.