NamePros
Welcome, Guest! Ready to make a name for yourself in the domain business? We welcome both the hobbyist and professional domainer to join the discussion as part of the NamePros community.

Click here to create your profile to start earning reputation for posting, and trader ratings for buying & selling in our free e-marketplace. Build your trader rating with each successful sale. Our system has tracked over 100,000 sales and counting!
FAQ & TOS Register Search Today's Posts Mark Forums Read

Go Back   NamePros.com > Website Development Discussion Forums > Programming
Reload this Page convert text to binary

Programming PHP, Perl, Ruby on Rails, AJAX, HTML, XHTML, CSS, JavaScript, MySQL and any other coding topics.

Advanced Search


Closed Thread
 
LinkBack Thread Tools
Old 04-04-2006, 11:48 AM THREAD STARTER               #1 (permalink)
NamePros Regular
 
edmarriner's Avatar
Join Date: Apr 2005
Location: England :D
Posts: 834
edmarriner is a jewel in the roughedmarriner is a jewel in the roughedmarriner is a jewel in the rough
 



convert text to binary


hi,

Is there any easy way in php to convert letters in to binary?
I just thought i would ask if there is any function before writing a long str_replace to replace the letters with binary code.

thanks,
-ed
__________________
Leeds united football club


edmarriner is offline  
Old 04-04-2006, 12:07 PM   #2 (permalink)
NamePros Member
Join Date: Mar 2006
Posts: 62
123finder.com is an unknown quantity at this point
 



Have you checked pack()?
http://us2.php.net/pack
__________________
123finder.com - Browse dictionary domains & 4-9 letter domains
123finder.com is offline  
Old 04-04-2006, 12:19 PM THREAD STARTER               #3 (permalink)
NamePros Regular
 
edmarriner's Avatar
Join Date: Apr 2005
Location: England :D
Posts: 834
edmarriner is a jewel in the roughedmarriner is a jewel in the roughedmarriner is a jewel in the rough
 



hi,


thanks for repling so fast.

i had a look at that page but i cant work out how i could do this.
any ideas?

im want 2 basicly.

have a string and convert the string into binary.

<?php
$text = "some text here";
//some function to convert the text into binary
echo"$text";
?>

and it would output:

01110011 01101111 01101101 01100101 00100000 01110100 01100101 01111000 01110100 00100000 01101000 01100101 01110010 01100101
__________________
Leeds united football club


edmarriner is offline  
Old 04-04-2006, 12:26 PM   #4 (permalink)
Senior Member
 
Eric's Avatar
Join Date: Mar 2005
Posts: 4,948
Eric Has achieved greatnessEric Has achieved greatnessEric Has achieved greatnessEric Has achieved greatnessEric Has achieved greatnessEric Has achieved greatnessEric Has achieved greatnessEric Has achieved greatnessEric Has achieved greatnessEric Has achieved greatnessEric Has achieved greatness
 

Member of the Month
MOTM September 2005
Save a Life Child Abuse 9/11/01 :: Never Forget Baby Health Marrow Donor Program AIDS/HIV Breast Cancer Animal Rescue Cystic Fibrosis Ethan Allen Fund Animal Cruelty Ethan Allen Fund Ethan Allen Fund Baby Health Cancer Alzheimer's Protect Our Planet Cancer Survivorship SIDS Child Abuse Diabetes Protect Our Planet Multiple Sclerosis Autism Adoption Special Olympics
See if you can use this..

PHP Code:
<html>
<head>
<title>Binary</title>
</head>

<body>

<form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
<textarea name="text" rows="10" cols="45"></textarea><br>
<input type="submit" name="submit" value="Convert!">
<input type="reset" value="Clear">
</form>

<?php

function binary($str)
{
  
$text_array explode("\r\n"chunk_split($str1));

  for(
$i 0$i count($text_array) - 1$i++)
  {
    
$newstring .= substr("0000".base_convert(ord($text_array[$i]), 102), -8);
????: NamePros.com http://www.namepros.com/programming/183726-convert-text-to-binary.html
  }
????: NamePros.com http://www.namepros.com/showthread.php?t=183726
  return 
$newstring;
}

if(isset(
$_POST['submit']))
{
  
$text trim(strip_tags(stripslashes($_POST['text'])));
  
$text chunk_split(binary($text), 8" ");
  
  echo 
$text;
}
?>

</body>
</html>
Eric is offline  
Old 04-04-2006, 12:29 PM   #5 (permalink)
mch
NamePros Regular
Join Date: Nov 2005
Location: EU
Posts: 248
mch is on a distinguished road
 



It's pretty simple to write this function but it is also kinda impossible because of the many different character code tables. It's not like in the old Pascal times with the chr() function
mch is offline  
Old 04-04-2006, 12:34 PM THREAD STARTER               #6 (permalink)
NamePros Regular
 
edmarriner's Avatar
Join Date: Apr 2005
Location: England :D
Posts: 834
edmarriner is a jewel in the roughedmarriner is a jewel in the roughedmarriner is a jewel in the rough
 



Wow,

Thankyou so much secondvision.
i am now for ever in in your debt.

Thanks mch and 123finder.com to for your help.

That was fast, i only started the thread 50 mins ago.

Thanks once again, rep added to every who helped.

-ed
__________________
Leeds united football club


edmarriner is offline  
Closed Thread


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools


Liquid Web Smart Servers  
All times are GMT -7. The time now is 05:42 AM.

Managed Web Hosting by Liquid Web
Domain name forum recommended by Domaining.com Powered by: vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.6.0 Ad Management plugin by RedTyger