[ale] php weirdness

James Sumners james.sumners at gmail.com
Mon Feb 23 14:24:34 EST 2009


That's not what your original post said you wanted to do. You said you
wanted to change "abc12345" to "-12345". The code you supplied should
have done just that. If you wanted to insert a '-' between "abc" and
"12345" you could have done:

$newstring = substr($foo, 0, 3) . '-' . substr($foo, 3);

On Mon, Feb 23, 2009 at 1:50 PM, Jim Kinney <jim.kinney at gmail.com> wrote:
> I'm bumfuzzled.
>
> Originally, my output was abcabc-12345. What I wanted was abc12345->
> abc-12345 (inserting a - between chars 3 & 4).
>
> echo str_replace(substr($row['foo'],0,3), substr($row['foo'],0,3).'-',
> $row['foo']);
> abc-12345
>
> is doing what it's supposed to do now.
>
> I ran the original version 8-10 times with same results (restarted web
> server, refreshed screen, added extra printf's , etc and each time I
> got a doubled abcabc. Now it works.
>
> Sometimes computers are just weird.


-- 
James Sumners
http://james.roomfullofmirrors.com/

"All governments suffer a recurring problem: Power attracts
pathological personalities. It is not that power corrupts but that it
is magnetic to the corruptible. Such people have a tendency to become
drunk on violence, a condition to which they are quickly addicted."

Missionaria Protectiva, Text QIV (decto)
CH:D 59


More information about the Ale mailing list