Headchopperz Posted January 20, 2009 Share Posted January 20, 2009 hey im working on a problem and i cant fix it http://forum.thegamecreators.com/?m=forum_view&t=143736&b=20 that is a lnk where i piuut a very detailed review on what i am stuck on ill go over it quickly in guild wars you get a code in BASE 64 and i need to convert it into Binary i explain on the other forums that every certain amount of number of digits i need together then i flip them eg 0110 1101 becomes 0110 1011 then i do more flipping etc and at the end i convert the binary to real numbers like 0011 is 3 and then using the numbers i find out the spell etc ive already done this by hand as shown on that link i just dont know how to get it working with PHP if java works with PHP which im sure it does than i dont mind it being in JAVA if its easier ty for your time Quote Link to comment https://forums.phpfreaks.com/topic/141639-base-64-to-binary-then-flip-parts-of-the-binary-to-real-numbers/ Share on other sites More sharing options...
RussellReal Posted January 20, 2009 Share Posted January 20, 2009 base_convert and to "flip" the numbers you could simply use array_walk on your exploded string for example <?php function flipele(&$ele) { $z = ''; for ($i = 0; ($a = $ele{$}) !== false; $i++) { $z = $a.$z; } $ele = $z; } $string = "0110 1011"; $arr = explode(" ",$string); array_walk($arr,"flipele"); print_r($arr); ?> Quote Link to comment https://forums.phpfreaks.com/topic/141639-base-64-to-binary-then-flip-parts-of-the-binary-to-real-numbers/#findComment-741413 Share on other sites More sharing options...
Headchopperz Posted January 20, 2009 Author Share Posted January 20, 2009 i ran ur code and visually it does nothing Quote Link to comment https://forums.phpfreaks.com/topic/141639-base-64-to-binary-then-flip-parts-of-the-binary-to-real-numbers/#findComment-741437 Share on other sites More sharing options...
Headchopperz Posted January 20, 2009 Author Share Posted January 20, 2009 Parse error: syntax error, unexpected '}', expecting T_VARIABLE or '$' in /home/danmake/public_html/outscape.org/test/index.php on line 4 i get that now =S Quote Link to comment https://forums.phpfreaks.com/topic/141639-base-64-to-binary-then-flip-parts-of-the-binary-to-real-numbers/#findComment-741508 Share on other sites More sharing options...
RussellReal Posted January 20, 2009 Share Posted January 20, 2009 the script I provided I have tested personally, and it works Quote Link to comment https://forums.phpfreaks.com/topic/141639-base-64-to-binary-then-flip-parts-of-the-binary-to-real-numbers/#findComment-741574 Share on other sites More sharing options...
Headchopperz Posted January 20, 2009 Author Share Posted January 20, 2009 why am i getting this error i have PHP 5 Quote Link to comment https://forums.phpfreaks.com/topic/141639-base-64-to-binary-then-flip-parts-of-the-binary-to-real-numbers/#findComment-741616 Share on other sites More sharing options...
Headchopperz Posted January 20, 2009 Author Share Posted January 20, 2009 heres the prove http://www.outscape.org/test/ Quote Link to comment https://forums.phpfreaks.com/topic/141639-base-64-to-binary-then-flip-parts-of-the-binary-to-real-numbers/#findComment-741618 Share on other sites More sharing options...
RussellReal Posted January 21, 2009 Share Posted January 21, 2009 show me the code of home/danmake/public_html/outscape.org/test/index.php Quote Link to comment https://forums.phpfreaks.com/topic/141639-base-64-to-binary-then-flip-parts-of-the-binary-to-real-numbers/#findComment-741783 Share on other sites More sharing options...
RussellReal Posted January 21, 2009 Share Posted January 21, 2009 oooh I'm sorry!!! lol I tested it then edited it and I messed it up <?php function flipele(&$ele) { $z = ''; for ($i = 0; ($a = $ele{$i}) !== false; $i++) { $z = $a.$z; } $ele = $z; } $string = "0110 1011"; $arr = explode(" ",$string); array_walk($arr,"flipele"); print_r($arr); ?> there use that bro I'm sorry Quote Link to comment https://forums.phpfreaks.com/topic/141639-base-64-to-binary-then-flip-parts-of-the-binary-to-real-numbers/#findComment-741876 Share on other sites More sharing options...
Headchopperz Posted January 21, 2009 Author Share Posted January 21, 2009 Fatal error: Maximum execution time of 30 seconds exceeded in /home/danmake/public_html/outscape.org/test/index.php on line 4 it obviously doesnt like me lol Quote Link to comment https://forums.phpfreaks.com/topic/141639-base-64-to-binary-then-flip-parts-of-the-binary-to-real-numbers/#findComment-742412 Share on other sites More sharing options...
RussellReal Posted January 21, 2009 Share Posted January 21, 2009 I'll test it again bro.. lol Quote Link to comment https://forums.phpfreaks.com/topic/141639-base-64-to-binary-then-flip-parts-of-the-binary-to-real-numbers/#findComment-742501 Share on other sites More sharing options...
RussellReal Posted January 21, 2009 Share Posted January 21, 2009 <?php function flipele(&$ele) { $z = ''; for ($i = 0; ($a = substr($ele,$i,1)) !== false; $i++) { $z = $a.$z; } $ele = $z; } $string = "0110 1011"; $arr = explode(" ",$string); array_walk($arr,"flipele"); print_r($arr); ?> Quote Link to comment https://forums.phpfreaks.com/topic/141639-base-64-to-binary-then-flip-parts-of-the-binary-to-real-numbers/#findComment-742504 Share on other sites More sharing options...
Headchopperz Posted January 21, 2009 Author Share Posted January 21, 2009 sweet ty dude lol that was quite funny it works now tyvm Quote Link to comment https://forums.phpfreaks.com/topic/141639-base-64-to-binary-then-flip-parts-of-the-binary-to-real-numbers/#findComment-742513 Share on other sites More sharing options...
GingerRobot Posted January 21, 2009 Share Posted January 21, 2009 Just fyi: there's already a function to reverse a string - strrev Quote Link to comment https://forums.phpfreaks.com/topic/141639-base-64-to-binary-then-flip-parts-of-the-binary-to-real-numbers/#findComment-742521 Share on other sites More sharing options...
RussellReal Posted January 21, 2009 Share Posted January 21, 2009 wow Quote Link to comment https://forums.phpfreaks.com/topic/141639-base-64-to-binary-then-flip-parts-of-the-binary-to-real-numbers/#findComment-742663 Share on other sites More sharing options...
Headchopperz Posted January 22, 2009 Author Share Posted January 22, 2009 would i use these http://uk.php.net/base64_decode base64 - binary http://uk.php.net/manual/en/function.trim.php or something better to remove all spaces in the binary http://uk.php.net/manual/en/function.wordwrap.php to count the amount of numbers and save into a new string http://uk3.php.net/strrev reverse the string Quote Link to comment https://forums.phpfreaks.com/topic/141639-base-64-to-binary-then-flip-parts-of-the-binary-to-real-numbers/#findComment-743604 Share on other sites More sharing options...
Headchopperz Posted January 22, 2009 Author Share Posted January 22, 2009 or http://uk.php.net/manual/en/function.substr.php Quote Link to comment https://forums.phpfreaks.com/topic/141639-base-64-to-binary-then-flip-parts-of-the-binary-to-real-numbers/#findComment-743605 Share on other sites More sharing options...
Headchopperz Posted January 22, 2009 Author Share Posted January 22, 2009 <?php $original = '00111010000001000100010101110000101101001001100110100000 10100110110001000011100110000110010001010110111100001011 10100000110100010111010001000100101001110000011010001001'; $neworiginal = substr($original,0,4) $neworiginal = strrev($neworiginal) $neworiginal = trim ( $neworiginal) echo $original echo $neworiginal ?> code ive been trying Quote Link to comment https://forums.phpfreaks.com/topic/141639-base-64-to-binary-then-flip-parts-of-the-binary-to-real-numbers/#findComment-743661 Share on other sites More sharing options...
RussellReal Posted January 23, 2009 Share Posted January 23, 2009 <?php function zwalk(&$element) { $element = strrev($element); } $original = '0111001101101101'; $originalArray = explode(' ',trim(chunk_split($original,4,' '))); array_walk($originalArray,'zwalk'); print_r($originalArray); ?> Quote Link to comment https://forums.phpfreaks.com/topic/141639-base-64-to-binary-then-flip-parts-of-the-binary-to-real-numbers/#findComment-744106 Share on other sites More sharing options...
Headchopperz Posted January 23, 2009 Author Share Posted January 23, 2009 after its fliped i need all the bits back together like 11001011 fliped = 0011 1101 then i need it to be = 00111101 <?php function zwalk(&$element) { $element = strrev($element); } $original = '00111010000001000100010101110000101101001001100110100000 10100110110001000011100110000110010001010110111100001011 10100000110100010111010001000100101001110000011010001001'; $oldarray = $originalArray; $originalArray = explode(' ',trim(chunk_split($original,6,' '))); $originalArray = $originalArray.$oldarray; array_walk($originalArray,'zwalk'); print_r($originalArray); print_r($oldarray); ?> that doesnt work >< Quote Link to comment https://forums.phpfreaks.com/topic/141639-base-64-to-binary-then-flip-parts-of-the-binary-to-real-numbers/#findComment-744427 Share on other sites More sharing options...
Headchopperz Posted January 23, 2009 Author Share Posted January 23, 2009 i made a working code but it needs arrays implemented cos its like loads of code xD <?php $original = '001110100000010001000101011100001011010010011001101000001010011011000100001110011000011001000101011011110000101110100000110100010111010001000100101001110000011010001001'; $neworiginal1 = substr($original,0,6); $neworiginal1 = strrev($neworiginal1); $neworiginal1 = trim($neworiginal1); echo $original; echo "\n stuff: "; echo $neworiginal1; echo " "; $neworiginal2 = substr($original,6,6); $neworiginal2 = strrev($neworiginal2); $neworiginal2 = trim($neworiginal2); echo $neworiginal2; echo " "; $neworiginal2 = substr($original,12,6); $neworiginal2 = strrev($neworiginal2); $neworiginal2 = trim($neworiginal2); echo $neworiginal2; echo " "; $neworiginal3 = substr($original,18,6); $neworiginal3 = strrev($neworiginal3); $neworiginal3 = trim($neworiginal3); echo $neworiginal3; echo " "; $neworiginal4 = substr($original,24,6); $neworiginal4 = strrev($neworiginal4); $neworiginal4 = trim($neworiginal4); echo $neworiginal4; echo " "; $neworiginal5 = substr($original,30,6); $neworiginal5 = strrev($neworiginal5); $neworiginal5 = trim($neworiginal5); echo $neworiginal5; echo " "; $neworiginal6 = substr($original,36,6); $neworiginal6 = strrev($neworiginal6); $neworiginal6 = trim($neworiginal6); echo $neworiginal6; echo " "; $neworiginal7 = substr($original,42,6); $neworiginal7 = strrev($neworiginal7); $neworiginal7 = trim($neworiginal7); echo $neworiginal7; echo " "; $neworiginal8 = substr($original,48,6); $neworiginal8 = strrev($neworiginal8); $neworiginal8 = trim($neworiginal8); echo $neworiginal8; echo " "; $neworiginal9 = substr($original,54,6); $neworiginal9 = strrev($neworiginal9); $neworiginal9 = trim($neworiginal9); echo $neworiginal9; echo " "; $neworiginal10 = substr($original,60,6); $neworiginal10 = strrev($neworiginal10); $neworiginal10 = trim($neworiginal10); echo $neworiginal10; echo "\n "; $newamount=$neworiginal1.$neworiginal2.$neworiginal3.$neworiginal4.$neworiginal5.$neworiginal6.$neworiginal7.$neworiginal8.$neworiginal9.$neworiginal10; echo $newamount; echo " "; $newamount1 = substr($newamount,0,4); $newamount1 = strrev($newamount1); $newamount1 = trim($newamount1); echo $newamount1; echo " "; $newamount2 = substr($newamount,4,4); $newamount2 = strrev($newamount2); $newamount2 = trim($newamount2); echo $newamount2; echo " "; $newamount3 = substr($newamount,8,2); $newamount3 = strrev($newamount3); $newamount3 = trim($newamount3); echo $newamount3; echo " "; $newamount4 = substr($newamount,10,4); $newamount4 = strrev($newamount4); $newamount4 = trim($newamount4); echo $newamount4; echo " "; $newamount5 = substr($newamount,14,4); $newamount5 = strrev($newamount5); $newamount5 = trim($newamount5); echo $newamount5; echo " "; $newamount6 = substr($newamount,18,4); $newamount6 = strrev($newamount6); $newamount6 = trim($newamount6); echo $newamount6; echo " "; ?> Quote Link to comment https://forums.phpfreaks.com/topic/141639-base-64-to-binary-then-flip-parts-of-the-binary-to-real-numbers/#findComment-744437 Share on other sites More sharing options...
RussellReal Posted January 24, 2009 Share Posted January 24, 2009 <?php function zwalk(&$element) { $element = strrev($element); } $original = '0111001101101101'; $originalArray = explode(' ',trim(chunk_split($original,4,' '))); array_walk($originalArray,'zwalk'); echo implode('',$originalArray); ?> Quote Link to comment https://forums.phpfreaks.com/topic/141639-base-64-to-binary-then-flip-parts-of-the-binary-to-real-numbers/#findComment-745144 Share on other sites More sharing options...
Headchopperz Posted January 24, 2009 Author Share Posted January 24, 2009 the problem is urs only does the firt but and theres like 4 bits i tried doing all 4 bits but it fails <?php function convert(&$binary) { $conbinary = substr($binary,$farin,-1); if $conbinary = 1; if $farin = 4 then $conbinary2=1 if $farin = 3 then $conbinary2=2 if $farin = 2 then $conbinary2=4 if $farin = 1 then $conbinary2=8 endif if $farin=1 $convertedbinary = $conbinary+$conbinary+$conbinary+$conbinary $farin=5 endif $farin = $farin-1; } function zwalk(&$element) { $element = strrev($element); } function cutitup(&$cutup) { if $binaryno=3 $cutup = 2 endif if $binaryno=1 $cutup = 6 endif if $binaryno=2 $cutup = 4 endif if $binaryno=4 $cutup = 8 endif $wayin = $wayin + $cutup substr($original,$wayin,$cutup); } function trimit(&$trimitup) { trim($trimitup); } function slapittogether(&$slapit) { $newamount = $neworiginal1.$neworiginal2.$neworiginal3.$neworiginal4.$neworiginal5.$neworiginal6.$neworiginal7.$neworiginal8.$neworiginal9.$neworiginal10.$neworiginal11; } $original = '00111010000001000100010101110000101101001001100110100000 10100110110001000011100110000110010001010110111100001011 10100000110100010111010001000100101001110000011010001001 '; $binary=1 //repeat untill the end, how do i do? array_walk($original,'trimit'); array_walk2($original,'cutitup'); array_walk3($original,'zwalk'); $newamount = $neworiginal1.$neworiginal2.$neworiginal3.$neworiginal4.$neworiginal5.$neworiginal6.$neworiginal7.$neworiginal8.$neworiginal9.$neworiginal10.$neworiginal11; // repeat twice $binary = 2 array_walk($original,'trimit'); array_walk2($original,'cutitup'); array_walk3($original,'zwalk'); // do once $binary = 3 array_walk($original,'trimit'); array_walk2($original,'cutitup'); array_walk3($original,'zwalk'); // repeat untill end $binary = 2 ?> Quote Link to comment https://forums.phpfreaks.com/topic/141639-base-64-to-binary-then-flip-parts-of-the-binary-to-real-numbers/#findComment-745216 Share on other sites More sharing options...
Headchopperz Posted January 24, 2009 Author Share Posted January 24, 2009 if u look here http://www.outscape.org/test/convert.php it does it all sole the converting well not exactly it all its too much code and too long winded its just doing part of it like the first half of the binary <?php $original = '00111010000001000100010101110000101101001001100110100000 10100110110001000011100110000110010001010110111100001011 10100000110100010111010001000100101001110000011010001001 '; $neworiginal1 = substr($original,0,6); $neworiginal1 = strrev($neworiginal1); $neworiginal1 = trim($neworiginal1); echo $original; echo "\n stuff: "; echo $neworiginal1; echo " "; $neworiginal2 = substr($original,6,6); $neworiginal2 = strrev($neworiginal2); $neworiginal2 = trim($neworiginal2); echo $neworiginal2; echo " "; $neworiginal3 = substr($original,12,6); $neworiginal3 = strrev($neworiginal3); $neworiginal3 = trim($neworiginal3); echo $neworiginal3; echo " "; $neworiginal4 = substr($original,18,6); $neworiginal4 = strrev($neworiginal4); $neworiginal4 = trim($neworiginal4); echo $neworiginal4; echo " "; $neworiginal5 = substr($original,24,6); $neworiginal5 = strrev($neworiginal5); $neworiginal5 = trim($neworiginal5); echo $neworiginal5; echo " "; $neworiginal6 = substr($original,30,6); $neworiginal6 = strrev($neworiginal6); $neworiginal6 = trim($neworiginal6); echo $neworiginal6; echo " "; $neworiginal7 = substr($original,36,6); $neworiginal7 = strrev($neworiginal7); $neworiginal7 = trim($neworiginal7); echo $neworiginal7; echo " "; $neworiginal8 = substr($original,42,6); $neworiginal8 = strrev($neworiginal8); $neworiginal8 = trim($neworiginal8); echo $neworiginal8; echo " "; $neworiginal9 = substr($original,48,6); $neworiginal9 = strrev($neworiginal9); $neworiginal9 = trim($neworiginal9); echo $neworiginal9; echo " "; $neworiginal10 = substr($original,54,6); $neworiginal10 = strrev($neworiginal10); $neworiginal10 = trim($neworiginal10); echo $neworiginal10; echo " "; $neworiginal11 = substr($original,60,6); $neworiginal11 = strrev($neworiginal11); $neworiginal11 = trim($neworiginal11); echo $neworiginal11; echo "\n "; $newamount = $neworiginal1.$neworiginal2.$neworiginal3.$neworiginal4.$neworiginal5.$neworiginal6.$neworiginal7.$neworiginal8.$neworiginal9.$neworiginal10.$neworiginal11; echo $newamount; echo "\n hi "; $newamount1 = substr($newamount,0,4); $newamount1 = strrev($newamount1); $newamount1 = trim($newamount1); echo $newamount1; echo " "; $newamount2 = substr($newamount,4,4); $newamount2 = strrev($newamount2); $newamount2 = trim($newamount2); echo $newamount2; echo " "; $newamount3 = substr($newamount,8,2); $newamount3 = strrev($newamount3); $newamount3 = trim($newamount3); echo $newamount3; echo " "; $newamount4 = substr($newamount,10,4); $newamount4 = strrev($newamount4); $newamount4 = trim($newamount4); echo $newamount4; echo " "; $newamount5 = substr($newamount,14,4); $newamount5 = strrev($newamount5); $newamount5 = trim($newamount5); echo $newamount5; echo " "; $newamount6 = substr($newamount,18,4); $newamount6 = strrev($newamount6); $newamount6 = trim($newamount6); echo $newamount6; echo " "; ?> Quote Link to comment https://forums.phpfreaks.com/topic/141639-base-64-to-binary-then-flip-parts-of-the-binary-to-real-numbers/#findComment-745218 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.