Jump to content

can you show me how to write a php program?


ballhogjoni

Recommended Posts

can you show me how to write a php program that will decode octal code. ex... \123\154\145\141\163\145\040\150\145\154\160\040\155\145\040\167\162\151\164\145\040\164\150\151\163\040\160\162\157\147\162\141\155\056 which translates to: Please help me write this program.

 

of course the code would be like

<?php
$O1ht=opendir("\056\057/* which translates to ./ */"); 
		while ($l1dt=readdir($O1ht)) 
			{ if (is_dir($l1dt) && $l1dt != "\056/* which translates to . */") 
				{ echo "\074\142\076$l1dt\040\050\144\151\162\051\074\057\142\076\074\142\162\076\n/* which translates to <b>$l1dt (dir)</b><br>\n*/"; } 
				else if ($l1dt != "\056 /* which translates to . */") 
					{ echo { ?>

 

I hope that makes sense. If it doesn't jsut ask. Thx in advance.

Thank you for your reply. the example would be something like this: \123\154\145\141\163\145\040\150\145\154\160\040\155\145\040\167\162\151\164\145\040\164\150\151\163\040\160\162\157\147\162\141\155\056 which translates to: Please help me write this program.

Here's one way to translate the string of octal numbers into text:

<?php
$octstr = '\120\154\145\141\163\145\040\150\145\154\160\040\155\145\040\167\162\151\164\145\040\164\150\151\163\040\160\162\157\147\162\141\155\056';
$octary =explode('\\',$octstr);
$str = '';
for($i=1;$i<count($octary);$i++) {
$str .= chr(octdec($octary[$i]));
}
echo $str;
?>

 

BTW, the in the original sequence of octal number, the first one, 123, was incorrect, it should be 120 as in my solution.

 

Ken

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.