View Single Post
  #3  
Old 08-05-2013, 12:02 PM
cbk1994 cbk1994 is offline
the fake one
cbk1994's Avatar
Join Date: Mar 2003
Location: San Francisco
Posts: 10,718
cbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond repute
Send a message via AIM to cbk1994
Without spending much time trying to understand your script, it's clear that your recursion is flawed. replaceVal(temp.newstring, temp.oldval, temp.newval); may or may not return anything, but it doesn't matter because you don't return that value, so the original call to the function won't see it. In other words, if the if-statement evaluates to true, which I'm guessing it does in the first call, there will never be a return value.

The echo you are seeing is actually from the deepest function call, and the value is returned correctly, but then you don't do anything with the return value when it is passed back to the same function. My guess is that simply adding return in front of the recursive call will fix it, but I'm not in a position to test it right now.
__________________
Reply With Quote