RChilton Posted February 13, 2014 Share Posted February 13, 2014 I have a field being imported from a .txt file. Each field has multiple ^ characters which need to be removed then each different sku in the field is separated by | to indicate a new sku. Some of the sku's have hyphens example 12345-6. As the code is written these skus do not show up because it is stripping the hypen out too and then it is an ureconizable sku. Currently the code is: $related=preg_replace("/[^a-zA-Z0-9|]/", "", $product['related']);$relatedrestricted = array('hospitalitymirrors', 'hospitalityaccessories', 'hospitalityfurniture', 'hospitalitylighting');if (!empty($related) && !in_array($cat, $relatedrestricted)){ $relatedItems = explode("|", $related); echo ("<tr> <td colspan=\"2\"> <h2>Related Products</h2> <ul id=\"relatedItems\"> "); foreach($relatedItems as $relatedItem) { if (isProduct($link, $relatedItem)) { echo ("<li> <a href=\"products.php?prod=$relatedItem&related=true\"> <img src=\"images/productimages/thumb_$relatedItem.jpg\" alt=\"View " . getName($relatedItem) . "\"/><br /> $relatedItem<br /> " . getName($relatedItem) . " </a> </li> "); } } Quote Link to comment Share on other sites More sharing options...
RChilton Posted February 13, 2014 Author Share Posted February 13, 2014 Okay I think I figured it out.... Replaced: $related=preg_replace("/[^a-zA-Z0-9|]/", "", $product['related']); With: $related=preg_replace('/[^A-Za-z0-9|() -]/', '', $product['related']); Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.