![]() |
Problem with CodeIgniter PHP function not changing variable - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: Problem with CodeIgniter PHP function not changing variable (/showthread.php?tid=33132) |
Problem with CodeIgniter PHP function not changing variable - El Forum - 08-16-2010 [eluser]Unknown[/eluser] Hi, I have a CodeIgniter class (not derived from anything) that has a function. This function is aimed at replacing keywords to link in a given text. The keywords are read from the DB. The problem I am having is that no matter what the $result is always the initial value. It seems that the variable retains its original content no matter what. I tried using other cycle types. The $result is not part of the query so I am clueless as to why it doesnt update. The value of result always reverts to the original string for some reason. It should incrementally keep replacing words in the string and return it. The $limit tells the cycle that it needs to stop after that amount of replacements have been made. I tried with an array, also inserting it into a db during iterations but always the same results. Please help as this is very annoying as I cannot find a solution. Thanks, Sintax Code: class String_Module Problem with CodeIgniter PHP function not changing variable - El Forum - 08-16-2010 [eluser]WanWizard[/eluser] The only way for $result to be identical after calling str_replace_first(), it if the $from is not found. When I test that function here, it replaces without problems. What is the result of that echo statement, when you change it to Code: echo "F=".$from." W=".$what." X=".($found?"TRUE":"FALSE")." C=$cnt <br/>"; Is $found TRUE? |