Jump to content

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.