RE: Converting a string into ASCII and a bit more - newbie

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Klaus,

Thanks you very much both for your quick reply and guidance. Yes, it now
works as it should.

I have a few further questions all related to the subject if you wouldn't
mind.

One is: how can I do the following (sort of maths) with a secondary string
of ascii values i.e. 25203030
with this result string from the first operation (65666768697071727374)
should be processed as
(65+25)(66+20)(67+30)(68+30)(69+25)(70+20)(71+30)(72+30)(73+25)(74+20)
So it actually is a nested loop but I am clueless how to accomplish this in
PHP.

Then finally I will convert the resulting ascii values string back into
chr's. I think I know how to do this. (Finally).

Thanks again for your time and help.

Alp

-----Original Message From: Klaus Reimer-----

Alp wrote:
> $x=1
> while ($x<=strlen($string)) {
>     $holder = ord(substr($string, $x, 1));
>     $result = $result . $holder;
>     }
> and failed since it takes ages to process and does not really return a 
> proper value/result but repetitive number such as 11111..........

I think you forgot to increment $x. Add an "$x++" at the end of your 
loop and it works.

And by the way: It's better to write "$result .= $holder" if you want to 
append a string to another. That's shorter and (more important) faster.

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux