<?
$fp = fopen ("binary.dat", "wb");
$buffer = 12345;
fwrite ($fp, $buffer);
fclose($fp);
?>
That creates a file 5 bytes long that contains the text data "12345", but I
need it to save that value as 32-bits instead (so the file would just be 4
bytes, with the contents being 0x39300000).
Anyone know how to do that? 4 1597
On Wed, 27 Apr 2005 02:00:50 +0800, "Dave Turner" <no****@nowhere.nohow> wrote: <? $fp = fopen ("binary.dat", "wb"); $buffer = 12345; fwrite ($fp, $buffer); fclose($fp); ?>
That creates a file 5 bytes long that contains the text data "12345", but I need it to save that value as 32-bits instead (so the file would just be 4 bytes, with the contents being 0x39300000).
Anyone know how to do that? http://uk.php.net/manual/en/function.pack.php
--
Andy Hassall / <an**@andyh.co.uk> / <http://www.andyh.co.uk>
<http://www.andyhsoftware.co.uk/space> Space: disk usage analysis tool
Thanks, but not quite what I meant. That converts the base, but it's still a
STRING ... ie. "11000000111001"
I need to save that as just 32-bits, so the file should only be 4 bytes
"ZeldorBlat" <ze********@gmail.com> wrote in message
news:11********************@g14g2000cwa.googlegrou ps.com... $someNum = 12345;
Convert to binary: $binNum = base_convert($someNum, 10, 2);
Convert to hex: $hexNum = base_convert($someNum, 10, 16);
http://www.php.net/manual/en/function.base-convert.php
pack() is the one i'm after, thanks. :) This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Randell D. |
last post by:
Folks,
I have a box that expects numeric input - I'd like to test for it (yeah,
I'll have service side checks too but also want client checks).
How can I test that my input is numeric - and...
|
by: anonieko |
last post by:
This applies to javascript dynamic textbox onkey
>
>
>
Newsgroups: comp.lang.javascript
From: Lasse Reichstein Nielsen <l...@hotpop.com> - Find messages by
this author
Date: Fri, 15 Jul 2005...
|
by: John J. Hughes II |
last post by:
I need to save a DWORD to the sql server, the below posts an error, any
suggestions on what I am doing wrong. I have the column in the sql server
defined as an int since unsigned int is not valid....
|
by: Keith |
last post by:
I apologize for those of you who think I'm posting on the same topic. It is not that I don't appreciate all of your comments - and I'm definitely reading them all - but I think I have a differing...
|
by: MLH |
last post by:
120 MyString = "How many copies of each letter do you need?"
150 MyVariant = InputBox(MyString, "How Many?", "3")
If MyVariant = "2" Then MsgBox "MyVariant equals the string '2'"
If...
|
by: liuliuliu |
last post by:
hi -- sorry if this is trivial -- but how do you make a screenshot of a
pygame display? i have a surface which is basically the entire visible
screen -- how do you write this surface as an image...
|
by: nishit.gupta |
last post by:
Is their any fuction available in C++ that can determine that a string
contains a numeric value.
The value cabn be in hex, int, float. i.e. "1256" , "123.566" ,
"0xffff"
Thnx
|
by: Mike |
last post by:
I use MS SQL EXPRESS DB
VS 2005, c#
Win Application
I have problem "The string is non-numeric"
with formula
CDbl({pr_DajPonudu;1.KolicinskiPopust})/100 * {@NajamProstora}
|
by: ryjfgjl |
last post by:
ExcelToDatabase: batch import excel into database automatically...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: jfyes |
last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
|
by: ArrayDB |
last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
|
by: PapaRatzi |
last post by:
Hello,
I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
|
by: CloudSolutions |
last post by:
Introduction:
For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
|
by: Defcon1945 |
last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
|
by: Shællîpôpï 09 |
last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
|
by: Faith0G |
last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
| |