pDid you know about the function str_replace ()? For those who are familiar with PHP of course never know this one function. If've never heard of before, then see this article.
This article will explain about what is the function str_replace (), its uses and examples of its use in scripts.
Function str_replace () in PHP include function in a group of string processing. Functionstr_replace () is used to replace a particular substring within a string. Confused? OK, Itake as an example.
Given a string such as 'I AM VERY HUNGRY ONCE'. Incidentally while writing thisarticle, indeed I'm hungry-hungry Well ... then I'll replace all substrings 'SA' to 'GI' in the given string. So will dihasikan new string 'GIYA GINGAT HUNGRY ONCE'. In PHP, the process of this substring replacement can be done with the command str_replace ()this.
What about the syntax? Here is the syntax of the function str_replace ()
str_replace(a, b, c);
where a is subtring to be replaced, b is subtring replacement, and c is the string initially.
Example of usage in the above case:
$stringAwal = "SAYA SANGAT LAPAR SEKALI";
$stringAkhir = str_replace("SA", "GI", $stringAwal);
Thanks for reading & sharing Agus Nur Ikhsan