Good evening everyone! I'm trying to use the str_replace()
method to replace a term within a variable, but it's not working.
foreach ($paginas as $pagina => $codigo) {
if(!strcasecmp($atual, $pagina)) {
str_replace("nav-link", "nav-link active", $codigo);
}
//Ao imprimir aqui, a substituição não surte efeito
echo $codigo;
}
I thought it would be because the variable $codigo
, which is the variable that foreach uses to assign the current value does not accept modifications, but maybe I'm wrong, so I came to ask them.