I am looking to create a system which on signup will create a subdomain on my website for the users account area.
Cisco Certified Network Associate Exam,640-802 CCNA All Answers ~100/100. Daily update
Cisco Certified Network Associate Exam,640-802 CCNA All Answers ~100/100. Daily update
I am trying to change a js program to php. there is a replace function like $t = t.replace(/B/g, "b");
if i change this to php as $t = str_ireplace(/B/g, "b",$t);
it shows error about "unexpecting '/' ". how to solve this.
First, JavaScript's replace function is closest to preg_replace.
ReplyDeleteSecond, if you read the docs for str_ireplace, it's case-insensitive replace, which given that you're trying to turn B into b is precisely the wrong function to use.
You can do $t = str_replace('B', 'b', $t); (simpler) or $t = preg_replace('/B/', 'b', $t); (can handle more complex situations than what you're doing).
That call to Javascript replace uses a regular expression as the search criterion.
ReplyDeleteThe PHP Equivalent is preg_replace