I have that function inside on a wp all import plugin for Wordpress to import products,that takes the first value and renames to the second value, a simple mapping function.
I want simply insert an condition that checking that strings and if isn't on that strings then the new string will be $cat=uncategorized>$cat in other words if isnt on my dictionary for example $cat=cars then i want to replace to uncategorized>cars
function cat_change($cat){
$cat = str_replace("XLARGE", "XL", $cat);
$cat = str_replace("xl", "XL", $cat);
$cat = str_replace("extralarge", "XL", $cat);
$cat = str_replace("XXL", "2XL", $cat);
$cat = str_replace("2XLARGE", "2XL", $cat);
$cat = str_replace("2large", "2XL", $cat);
$cat = str_replace("2xlarge", "2XL", $cat);
$cat = str_replace("XXXL", "3XL", $cat);
$cat = str_replace("3XLARGE", "3XL", $cat);
$cat = str_replace("3large", "3XL", $cat);
$cat = str_replace("3xlarge", "3XL", $cat);
return $cat;
}
source https://stackoverflow.com/questions/69788947/php-string-condition-check-for-plugin
Comments
Post a Comment