Remove everything before specific character
-
Hi,
We need to remove everything before a specific character in a product attribute. Example:
Product attribute (sizes): 10042-25-XS
We want to change it to only: XSIn the product attribute we have added the following:
[strtest({merchant_product_id[1]})]
Screenshot:
https://prnt.sc/pn27oqSo far we have added the following code to our functions.php, but it doesn’t seem to work:
function strtest( $str, $char, $strpos) { $str = merchant_product_id[1]; $char = " - "; $strpos = strpos($str, $char); $str = substr($str, $strpos+strlen($char)); //Extract the substring after the separator echo $str; }Screenshot:
https://prnt.sc/pn27a1Hope you can help 🙂
Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
The topic ‘Remove everything before specific character’ is closed to new replies.