I am reading random bytes from /dev/urandom, and I want to make a random float out of it/them. How would I do this? I can convert the byte to a number with ord(), and it's between 0 and 255.
It's obvious that 255 is 1.0, 127 is 0.5 and 0 is 0.0, but how do I calculate the rest? Also, I think one byte is not enough to give lots of preci...
What would be the most efficient way to select every nth item from a large array? Is there a 'smart' way to do it or is looping the only way?
Some points to consider:
The array is quite large with 130 000 items
I have to select every 205th item
The items are not numerically indexed, so for($i = 0; $i <= 130000; $i += 205) won't work
...
I've never done any curl before so am in need of some help. I've tried to work this out from examples but cannot get my head around it!
I have a curl command that I can successfully run from a linux(ubuntu) command line that puts a file to a wiki through an api.
I would need to incorporate this curl command in a PHP script I'm building...
I am trying to load Google custom XML search results into a PHP page and then manipulate the XML using JQuery.
I understand that I can't use javascript to grab the XML file as it's on an external domain but can I use PHP to grab the XML from the server and then make it available to JQuery as an XML file, or other DOM structure, so I ca...
Hi,
I Am new PHP.How to send a SMS using PHP?
...
I am successful in uploading to amazon s3 bucket using post and swf upload but can any one tell me how to upload to a subdirectory inside my bucket.
I am using php as my server side language.
Thanks in advance
...
Can anyone help me figure out how to search a URL and print a class based on its result for example:
http://www.?.com/garden-design.html
What i am trying to achieve is using a switch using PHP mathcing a term of say "garden" after the first trailing slash then it would print a class. If it matched construction it would print a differ...
I need to convert data points from one geographic projection (Lat Long, Mercator, UTM) to another and I wonder if there's a set of PHP tools or functions that can do this? I tried writing one myself based on formulas I found, but it wasn't accurate enough and I can't find better formulas anywhere, so I was wondering if there might be som...
Hey I have seen sites that instead of an int show you a string.
For example d2fr4st == 147392525 and d2fr4ss == 147392524. What base is this? And how can I do the same conversion in php and .NET?
At the moment converting from 147392524 to d2fr4ss would be most useful.
...
I am working on a Drupal-based website that works fine on the remote server (LAMP stack) as well as all other developer's systems (WAMP stack). But when I try to run it, the PHP code is spit out in the browser along with the HTML instead of being parsed like it should.
There's very little information that I can glean from error logs. PH...
I am creating a game web site using PHP and I want to just use one page for the game rather than have a bunch. I want to have the info entered like this:
`?swf=[path to .swf]&name=[name of game]&description=[Description of Game]&instruction=[Instructions for game]``
The problem is that if there is no data entered in the URL it returns ...
Hello All,
I use:
window.print();
to print documents.
Problem:
As you guys know that browsers automatically adds page's title, path on top of the print page and page number and date on footer of the page.
But the client has asked me to remove all those things from the page or change their color to white so that they are not visibl...
I have a PHP script that uses adds a lot of small files into the same zip arhchive file using PHP's ZipArchive class.
Recently script started to run out of memory, although the archive is large, but I add only small files one by one, safely re-opening archive each time I need to add a file.
The initial archive file grew little by littl...
I'm using opennssl_random_pseudo_bytes() in PHP and it is performing ultra slowly. My application often timeouts (throws that execution time limit error). Is there a particular reason for OpenSSL random to be this slow? I'm using Windows 7 x86 currently on my developer machine.
...
I am writing a payment gateway for WP eCommerce (http://www.instinct.co.nz/e-commerce/) The merchant requires the user to be redirected to the merchants website (similar to paypal express I believe). Once the user has completed the transaction (successfully or not) they are redirected back to the transaction results page of WP eCommerce ...
I have a page which lists a load of portfolios.
I am trying to write a script which will look in a specific folder of images (the projects image folder) for a image called portfolio.jpg. When this image is found the image would be resized to a specific dimension keeping its filename the same.
Then obviously the next time this script...
Database one is called widgets, it has "id" and "title". Database two is called widget-layouts and it has "module-id", "widget-id", "position", and "weight".
What I am trying to do is check to see if widgets.id exists in widget-layout.widget-id and if it does, then does widget-layouts.position = 0. I also want to get the values of widge...
I want to update a table:
$result=mysql_query("select balance from tablename where userid='$userid")or die(mysql_error());
$row=mysql_fetch_assoc($result);
$accountbalance=$row['balance'];
if($accountbalance>$cost)
{
$result=mysql_query("update tablename set balance-'$cost' where userid='$userid")or die(mysql_error());
}
else {
...
}
...
Helo there, im trying to figure out how to write a function that returns a multidimensional array, based on the data below:
I know how to write the function using the "category_parent" value, but im just trying to write a function that can create a multidimensional array by JUST using the left and right keys.
Any help greatly appreciat...
Is there a quick way to calculate date difference in php? For example:
$date1 = '2009-11-12 12:09:08';
$date2 = '2009-12-01 08:20:11';
And then do a calculation, $date2 minus $date1
I read php.net documentation, but no luck. Is there a quick way to do it?
EDIT:
I will put up the whole answer (for some people who might curious of ho...