I have some large HEX values that I want to display as regular numbers, I was using hexdec() to convert to float, and I found a function on php.net to convert that to decimal, but it seems to hit a ceiling, eg:
$h = 'D5CE3E462533364B';
$f = hexdec($h);
echo $f .' = '. exp_to_dec($f);
Output: 1.5406319846274E+19 = 154063198462...
I have a string that looks like this:
'p10005c4'
I need to extract the productId 10005 and the colorId 4 from that string into these variables:
$productId
$colorId
productId is > 10000.
colorId > 1.
How can I do this clean and nice using regex?
...
Hello,
I just started my adventure with zend framework 1.9.1 but I encountered few issues. I would like to remove default routes to avoid displaying the same content on different URLs - to achive it I wrote custom function in bootstraper
<?php
class Bootstrap extends Zend_Application_Bootstrap_Bootstrap
{
protected function _initM...
Hierachical Data from SQL
Adjacency List Model
In my model I have a series of objects, each stored with their parent id. I am using the Adjacency list model as my hierachy method.
All examples of Adjacency list simply output there and then. None try to create a multi dimensional array from the result set.
---------------
| id | paren...
I'm looking for a way to get all the form inputs and respective values from a page given a specific URL and form name.
function GetForm($url, $name)
{
return array
(
'field_name_1' => 'value_1',
'field_name_2' => 'value_2',
'select_field_name' => array('option_1', 'option_2', 'option_3'),
);
}
GetForm('http:/...
The deeper I get with Drupal the more I have to make changes to code within other people's modules. These are usually small changes, and so far it doesn't make sense to rewrite the module's functionality for my own needs.
I'm trying not to make any modifications to Drupal core since that just seems like asking for trouble.
But sooner ...
This answer is based on this answer.
Cha uses arrays in storing login -info in contrast to my code.
It likely improves the efficiency in searching the login -data and keeps your data organized.
However, I am not sure whether this is the best data structure in storing all pieces of the login info.
My solution always fetches passhash fro...
In PHP, I am trying to validate an XML document using a DTD specified by my application - not by the externally fetched XML document. The validate method in the DOMDocument class seems to only validate using the DTD specified by the XML document itself, so this will not work.
Can this be done, and how, or do I have to translate my DTD t...
I have a small problem - I want to decrease code duplication in my site, and the best way that I can see of doing that is to remove a lot of unnecessary instances of variable setting.
One of the most common is the $baseUrl variable, which contains the http host and php self values, for convenience. However, I have to set it for each fun...
hi,
I have a javascript function that takes in a parameter that is given by a php session.
This works well except when the value is from a text area that contains a newline character.
I guess it appears as if I'm passing in a parameter and then the newline indicates I have stopped or something like that. Please advise on how to fix this...
From inside a PHP program I want to know the location of the binary executing it. Perl has $^X for this purpose. Is there an equivalent in PHP?
This is so it can execute a child PHP process using itself (rather than hard code a path or assume "php" is correct).
UPDATE
I'm using lighttpd + FastCGI, not Apache + mod_php. So yes, the...
What is the easiest way to code in the values in fifteen minute increments? In other words, instead of doing the following:
<select>
<option value="">12:00 AM</option>
<option value="">12:15 AM</option>
<option value="">12:30 AM</option>
<option value="">12:45 AM</option>
... so on
How could I use PHP to take up less space?
Thanks!...
I have the Python expression n <<= 1
How do you express this in PHP?
...
I'm using PHPUnderControl which runs on top of Cruise Control for my continuous integration and unit testing. I also have it setup to run PHPDocumentor to generate phpdoc's for me and it runs PHP Code Sniffer to enforce coding standards for me. But now I want to set up something on that same server (Ubuntu) to make deploying to a remote ...
As I prepare to tackle the issue of input data filtering and sanitization, I'm curious whether there's a best (or most used) practice? Is it better to filter/sanitize the data (of HTML, JavaScript, etc.) before inserting the data into the database, or should it be done when the data is being prepared for display in HTML?
A few notes:
...
Which of the following ways is the right one in using the characters " and ' inside PHP's sub-arrays?
#1 Way in debugging PHP code
$_POST["login['username']"];
#2 My original way in PHP
$_POST['login[username]'];
My code is now broken after changing all my variables to arrays.
The following is the HTML to which the variables re...
Ok this might sound like a dumb question but bear with me. I am trying to make it so that when people go to example.php?id=1, example.php?id=2, example.php?id=3 etc they see different data called from an included file filling in the blanks.
I have a variable called $offername and I want to display $offer1name, $offer2name, $offer3name...
I want to create a simple auditing system for my small codeigniter application such that it would take a snapshot of a table entry before the entry has been edited.
One way I could think of would be to create a for example news_audit table which would replicate all the columns in the news table and create a new record for each change w...
I'm running XAMPP on my local machine and on a server in the office. Both are Windows machines.
I'm writing some code that uses mail() to send email from a form. By default, it uses sendmail.exe (which comes with XAMPP) to send the email. In all cases, the mail is actually sent via a third machine, which is the Exchange server.
From m...
I'm trying to connect to Gmail through IMAP with PHP running in Apache. This is on an Ubuntu 9.04 system. I've got some sort of PHP configuration issue that is keeping this from working. First, here's what I did to setup IMAP for PHP:
sudo apt-get install libc-client2007b libc-client2007b-dev
sudo apt-get install php5-imap
sudo /etc/...