Re: converting text to binary code
| From: | Perry Loh | Date: | Fri, 08 Sep 2000 06:36:23 +0000 |
| Subject: | Re: converting text to binary code | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-15835@lists.php.net to get a copy of this message | ||
You would want to do something like
$normStr = unpack("A*vals',$binStr);
All the ascii characters would then be returned in an associative array of
$normStr in which you would refer to as ......
$normStr["vals1"]
$normStr["vals2"]
$normStr["vals3"]
.................
and so forth
You would probably want to loop thru the array to echo all the values back
out.
""Scott Mebberson"" <scott@redbluedesign.com.au> wrote in message
news:8p9qnf$a7u$1@toye.php.net...
> I have a text field(name=convertStr) in which you enter some text then
click
> the submit button.
>
> If thens parses the variable $convertStr to the new script below:
>
> <?php
> $curVersion = ".001";
>
> $binStr = pack ("A", "$convertStr");
> $normStr = unpack ("A", $binStr);
>
> echo ("normal string = $convertStr<br>\n");
> echo ("binary string = $binStr<br>\n");
> echo ("unpacked binary = "normStr[A]<br>\n");
> ?>
>
> All I want it to do is take $convertStr convert it to binary code and set
> the value to $binStr, the decode $binStr back in to text format as
$normStr.
>
> I don't know what method to use. It isn't explained very well at all on
> php.net manaual.
>
> can anybody help me??
>
> thanks
>
> Scott.
>
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net
> For additional commands, e-mail: php-general-help@lists.php.net
> To contact the list administrators, e-mail: php-list-admin@lists.php.net
>