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='';}  

preg_replace


Comments

Popular posts from this blog

1111. appearing after print sequence - php -

java - WARN : org.springframework.web.servlet.PageNotFound - No mapping found for HTTP request with URI [/board/] in DispatcherServlet with name 'appServlet' -

Ruby on Rails, ActiveRecord, Postgres, UTF-8 and ASCII-8BIT encodings -