Jump to content

A better way?


rarebit

Recommended Posts

Hi, is there a better way to find if a key 'partially' exists in an array. When I say better I mean a built in function? Heres what i've scraped together:

$key = -1;
foreach($_POST as $k => $v)
{
	if(strcmp("SUB_", substr($k, 0, 4))==0)
	{
		$key = $k;
		break;
	}
}

 

It comes from a submit button and probably not allowed to use an array of buttons...

 

Cheers!

Link to comment
https://forums.phpfreaks.com/topic/105144-a-better-way/
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.