Post Reply 
REPLACE Doesn't.
03-31-2017, 01:48 PM (This post was last modified: 03-31-2017 05:28 PM by Dieter.)
Post: #2
RE: REPLACE Doesn't.
(03-31-2017 01:40 PM)toml_12953 Wrote:  
PHP Code:
for i from 1 to 4 do
   
replace(x,i,"0");
  
end

This probably is a very dumb answer, as I do not even have a Prime at hand to check it. But in all programming languages I know the "replace" string function does not replace the i–th character, instead it replaces one substring by another. Like this:

replace("apple pie", "apple", "orange") => "orange pie"

So the right approach may be something like a simple replace(x," ","0"). No for-loop required.

But again: probably this is a very stupid answer. You should know since you've got the manual. ;-)

Dieter

Edit: replaced a 9 with a 0.
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
REPLACE Doesn't. - toml_12953 - 03-31-2017, 01:40 PM
RE: REPLACE Doesn't. - Dieter - 03-31-2017 01:48 PM
RE: REPLACE Doesn't. - toml_12953 - 03-31-2017, 02:06 PM
RE: REPLACE Doesn't. - Han - 03-31-2017, 02:10 PM
RE: REPLACE Doesn't. - toml_12953 - 03-31-2017, 02:15 PM
RE: REPLACE Doesn't. - Tim Wessman - 03-31-2017, 03:59 PM
RE: REPLACE Doesn't. - Dieter - 03-31-2017, 05:25 PM
RE: REPLACE Doesn't. - toml_12953 - 04-01-2017, 12:25 AM
RE: REPLACE Doesn't. - eried - 03-31-2017, 01:53 PM



User(s) browsing this thread: 1 Guest(s)