Reputation: 1
I am trying to stop the html br command from apearing in this code as some product titles have a br tag in the title:
<input id="product" name="product" type="text" value="<?php echo $products_name ?>" class="form-control">
Upvotes: 0
Views: 1087
Reputation: 575
How about this:
<input id="product" name="product" type="text" value="<?php echo strip_tags($products_name) ?>" class="form-control">
That would remove all HTML tags from the products_name, which I think would generally be a good idea if you're not sure if there will be any tags present ;)
Upvotes: 0
Reputation: 34837
Assuming the <br>
is inside the $products_name
variable, you can simply use the strip_tags function on it, like:
value="<?php echo strip_tags($products_name); ?>"
This also disallows any other HTML in the title, but that would make much sense in this context anyway.
Upvotes: 0
Reputation: 111
Try this, use str_replace()
<input id="product" name="product" type="text" value="<?php echo str_replace("<br/>", "", $products_name) ?>" class="form-control">
Upvotes: 1