ballhogjoni Posted February 11, 2007 Share Posted February 11, 2007 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. Link to comment https://forums.phpfreaks.com/topic/38085-can-you-show-me-how-to-write-a-php-program/ Share on other sites More sharing options...
trq Posted February 11, 2007 Share Posted February 11, 2007 I hope that makes sense. Sorry, I don't see any question. Link to comment https://forums.phpfreaks.com/topic/38085-can-you-show-me-how-to-write-a-php-program/#findComment-182306 Share on other sites More sharing options...
ballhogjoni Posted February 11, 2007 Author Share Posted February 11, 2007 can you show me how to write a php program that will decode octal code. I just manually decoded the octal code. Link to comment https://forums.phpfreaks.com/topic/38085-can-you-show-me-how-to-write-a-php-program/#findComment-182309 Share on other sites More sharing options...
trq Posted February 12, 2007 Share Posted February 12, 2007 I imagine it would depend on what you want to convert the octal code too. octdec will convert octal to decimal. Maybe if you gave an example of the usage we could help more. Link to comment https://forums.phpfreaks.com/topic/38085-can-you-show-me-how-to-write-a-php-program/#findComment-182319 Share on other sites More sharing options...
ballhogjoni Posted February 12, 2007 Author Share Posted February 12, 2007 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. Link to comment https://forums.phpfreaks.com/topic/38085-can-you-show-me-how-to-write-a-php-program/#findComment-182329 Share on other sites More sharing options...
giba Posted February 12, 2007 Share Posted February 12, 2007 [i]Hey, do you want php to translate simple text to octal or octal to simple text?[/i] Link to comment https://forums.phpfreaks.com/topic/38085-can-you-show-me-how-to-write-a-php-program/#findComment-182357 Share on other sites More sharing options...
fert Posted February 12, 2007 Share Posted February 12, 2007 http://us3.php.net/manual/en/function.base-convert.php Link to comment https://forums.phpfreaks.com/topic/38085-can-you-show-me-how-to-write-a-php-program/#findComment-182358 Share on other sites More sharing options...
kenrbnsn Posted February 12, 2007 Share Posted February 12, 2007 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 Link to comment https://forums.phpfreaks.com/topic/38085-can-you-show-me-how-to-write-a-php-program/#findComment-182396 Share on other sites More sharing options...
ballhogjoni Posted February 12, 2007 Author Share Posted February 12, 2007 giba, octal to simple text as in my example Link to comment https://forums.phpfreaks.com/topic/38085-can-you-show-me-how-to-write-a-php-program/#findComment-182417 Share on other sites More sharing options...
ballhogjoni Posted February 12, 2007 Author Share Posted February 12, 2007 Thx Ken, Is there a program that can run thru and decode an entire page of php? Link to comment https://forums.phpfreaks.com/topic/38085-can-you-show-me-how-to-write-a-php-program/#findComment-182422 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.