John Davidson

regex - PHP String replace Input element to span

0 comments
Message:


I have the below string with the multiple input elements


$str = '<input style="font-size:12px;width:100%" type="text" value="http://www.google.de/ggg">';

I want to convert this to


'<span style="font-size:12px;width:100%">http://www.google.de/ggg</span>';

How I can do it using PHP



My Answer:


';
I want to replace all the input elements with span elements. Here is the PHP code using regex to achieve this:
php
$str = '

';
$newStr = preg_replace('//', '', $str);
echo $newStr;

This code will replace all input elements with span elements in the given string.

Rate this post

3 of 5 based on 8742 votes

Comments




© 2024 Hayatsk.info - Personal Blogs Platform. All Rights Reserved.
Create blog  |  Privacy Policy  |  Terms & Conditions  |  Contact Us