-
-
Save N-Molham/7d05c6430e7aea761eed0d6a99232d44 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function my_condition( $original ) | |
{ | |
if ( is_numeric( $original ) ) | |
$original = absint( trim( $original ) ) >= 2016 ? 'new' : 'used'; | |
$makes = array( | |
'cons' => 'Used', | |
'used' => 'Used', | |
'U' => 'Used', | |
'new' => 'New', | |
'N' => 'New', | |
); | |
return match_convert( $original, $makes ); | |
} | |
function match_convert( $original , $words = '' , $default = 'Used' ) | |
{ | |
if ( empty( $words ) ) | |
return $default; | |
foreach ( $words as $matching_word => $replacement ) | |
{ | |
if ( false !== strpos( mb_strtolower( $original ), mb_strtolower( $matching_word ) ) ) | |
return $replacement; | |
} | |
return $default; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment