php - str_replace is replacing all but 1 section of my string correctly. -
my original string looks
value='' tabindex='500'
i replace string
value='email:' tabindex='500' onclick=\"if (this.value=='email:') {this.value='';}
so use str_replace function
$userform = str_replace("value='' tabindex='500'", "value='email:' tabindex='500' onclick=\"if (this.value=='email:') {this.value='';}\"",$userform); my output ends being
value="" tabindex="500" onfocus=" if (this.value == '') { this.value = ''; }" if notice, except parts include 'value="email:" replaced correctly...
i hoping might have idea on why happening? appreciated. thank in advance!
you may looking like:
$userform = preg_replace('/value=\'\' tabindex=\'(.*?)\'/i', 'value=\'email:\' tabindex=\'$1\' onclick="if (this.value==\'email:\') {this.value=\'\';}', $userform); result:
value='email:' tabindex='500' onclick="if (this.value=='email:') {this.value='';}
Comments
Post a Comment