random - How to randomize a hex value between ''00' - 'FF' in PHP
Get the solution ↓↓↓So, through PHP I am trying to randomize a hex value between 00 and FF. I want to use this as a value for (example):
fseek($f, '0x01B6F0');
fwrite($f, pack('c', hexdec(""MY RANDOMIZED VALUE")));
I see some examples on my internet searches on how to randomize the location, by which I mean 0x000000 - 0xFFFFFF, but I am only interested in the value. Sorry, I don't know the lingo like 'offset' and such to clearly state what I mean, but I think I stated it well enough to get suggestions on how to do this (like '0C' or '47'... or 0x01B6F0:0C). Thanks!
Answer
Solution:
As mentioned in the comments, generate a number between 0 and 255 and then usedechex()
to convert decimal to hex (and nothexdec()
)...
echo dechex(rand(1,255))
Share solution ↓
Additional Information:
Link To Answer People are also looking for solutions of the problem: script cache:clear returned with error code 255
Didn't find the answer?
Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.
Similar questions
Find the answer in similar questions on our website.
Write quick answer
Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.