Partial String Match of Values in an array

I have a list of values in an array that I need to return a result on a partial match.  I have figured out how to do the exact match, but for certain reason, I'd like to be able to return a value based on a partial match of the values.  This is what I have working for the exact match method:

<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">

<body bgcolor="#FFFFFF">
function array_find($needle, array $haystack)
    foreach ($haystack as $key => $value) {
        if (false !== stripos($needle, $value)) {
            return $key;
    return false;

$entrymethod = $_POST['entrymethod'];
$shipmethod_match = array('UPS Red' => 'United Parcel Service (UPS Next Day Air):', 
								'UPS Blue'=>'United Parcel Service (UPS 2nd Day Air):',
								'UPS Ground'=>'United Parcel Service (UPS Ground):', 
								'UPS WW Express'=>'United Parcel Service (UPS Worldwide Express):',
								'UPS WW Expedite'=>'United Parcel Service (UPS Worldwide Expedited):', 
								'UPS Standard' => 'UPS Standard:', 
								'UPS 3 Day' => 'United Parcel Service (UPS 3 Day Select):', 
								'UPS Blue AM' => 'United Parcel Service (UPS 2nd Day Air A.M.):', 
								'Free Shipping' => 'Free Shipping:', 
								'Third Party' => 'Recipient/Third Party Account (No shipping charge added<br><small><b><span style="color:red;">*Note:</span></b> Please enter your account number in the Comments area.</small>):',
								'Flat Rate' => 'Flat Rate Shipping (Standard Ground Service):',
								'Store Pickup' => 'Store Pickup (No shipping charge added.  Pickup during regular business hours.):' );

$matched2 = array_find($entrymethod, $shipmethod_match);

<form method="POST" action="<?php echo $PHP_SELF; ?>">
<input type="text" name="entrymethod">
<input type="submit" value="match">

echo 'matched2: '. $matched2 .'<br>';

Open in new window

For instance, for the "Third Party" value, I would like to be able to just enter something like Third Party, or Recipient/Third Party Account and be able to display the result.  I am not worried about multiple matches because my values and entries will be unique.  I have tried preg_match, and preg_grep functions, but I don't seem to be able to work out the syntax to make it work.  

Is there a function that will help return the matched value on a partial match?
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

zephyr_hex (Megan)DeveloperCommented:
In your array_find function, change this line:

 if (false !== stripos($needle, $value)) {

Open in new window

to this:

if (false !== stripos($value, $needle)) {

Open in new window

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
FourMatAuthor Commented:
Ugh, that works perfectly.  I knew there was something that I was missing.  Thank you!
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.