I have an array of 200 items. I would like to output the array but group the items with a common value. Similar to SQL's GROUP BY method. This should be relatively easy to do but I also need a count for the group items.
Does anyone have an efficient way of doing this? This will happen on every page load so I need it to be fast and scala...
and the database is MYSQL
...
I have a very special case in which I need to call a protected method from outside a class. I am very conscious about what I do programmingwise, but I would not be entirely opposed to doing so in this one special case I have. In all other cases, I need to continue disallowing access to the internal method, and so I would like to keep the...
I'm a newcomer to regular expressions, and am having a hard time with what appears to be a simple case.
I need to replace "foo bar" with "fubar", where there is any amount and variety of white space between foo and bar.
For what it's worth, I'm using php's eregi_replace() to accomplish this.
Thanks in advance for the help.
...
I'm getting an array of strings from a JSON object. I want to save these strings in a DB, but only if they're not already in there. What's the best way to compare what's already in the DB with what I'm about to enter, and exclude matches?
I'm using PHP and MySQL. Thanks!
...
I am making an admin panel for a small project. I want to use dynamic URLs to edit specific data entries. For instance:
file.php?edit&n=53
I want this URL to edit entry 53.
I use a switch statement to check for the edit page, but how do I check whether or not the URL has the &n=x extension in the same switch statement?
Ex:
switch $...
I'm coding a web interface to a horrible piece of propitiatory software our company uses. the software has no real UI and requires us giving putty access to our system for our clients to even pull data. My web interface has to run an exec(); function and it has to pass a few variables the user inputs.
$command = "report-call '$type' '$s...
I am having a serious problem converting my 'select' statement into something that will work with the zend paginator... could someone have a crack at it, as I am having no luck...
Here is my query:
$query = "SELECT
user_id, name, gender, city, province, country, image_id, one_liner, self_description, reputation
FROM
...
I'm investigating the best place to set my error logging options, and it seems the most reliable place would be in .htaccess in the script subdirectory. But this particular script is run via cron, and therefore via command line.
Do php_value settings made in .htaccess affect scripts that are not run through the web server?
...
I have images stored in mysql as mediablobs, and I'd like to load (show) them directly from the database without having to save them as files first.
I need to load multiple images into a table (thumbs), so the header command won't do it.
this is what I do:
$imagePath = 'files' . DS . 'recipe_' . $recipe['Recipe']['id'] . '.tmp';
...
Given my generic select below, is there a way to get the number of records returned from a query with Zend Framework? $row++ in a loop is not acceptable for my solution as I am using paging (though its not in my sample).
I also DO NOT want to add another query with "Count(*)".
$query = "Select * from Users where active = 1";
$stmt = $...
If you have DOMNode in PHP, how can you get the outer xml (i.e. the all of the XML that is inside this element plus the element itself)?
For example, lets say this is the structure
<car>
<tire>Michelin</tire>
<seats>Leather</seats>
<type>
<color>red</color>
<make>Audi</make>
</type>
</car>
And I have a pointer to the <type>...
My situation: I have a class that I want to use in a number of places, so I placed it high in the directory tree:
/www/libs/classA/classA.php
It uses a config file located in the same directory called config.ini and references it locally in the constructor. However, when I include it from a script in a different directory, it tries to...
$socket = socket_create(AF_INET, SOCK_DGRAM, SOL_UDP);
socket_bind($socket, $ip_server , $port);
socket_sendto($socket, $ascii_egyben_kimenet, strlen($ascii_egyben_kimenet), 0, $ip_plc , $port);
$valasz_kimenet=socket_read($socket, 256);
Because the socket_read the server is waiting for an answer...
How I can define the max time to wa...
Is there an equivalent of PHP's preg_match_all in Javascript? If not, what would be the best way to get all matches of a regular expression into an array? I'm willing to use any JS library to make it easier.
...
Hiya,
I've been shifting through the drupal documentation and forums but it's all a little daunting. If anyone has a simple or straight forward method for adding fields to the Site information page in the administration section i'd really appreciate it.
As a background, i'm just trying to add user customizable fields site wide fields/...
Greetings,
I am trying to debug a login script. So I decided to use var_ dump to print out the password. But for some reason say If I type in 'BOSTON' rather then printing 'BOSTON' it prints out six dashes, 1 dash for each character. I haven't encountered it like this before. I'm sure i'm missing something. I tried ob_ start() var_ dump...
In our current use of memcached, we are running into problems in a high volume server because so much time is used setting up and tearing down connections to our memcache server. Would using persistent connections to memcached help alleviate this problem?
Also, what is the preferred way to connect and use persistent memcahced connectio...
Background: When generating HTML content with PHP or any such thing, it is possible to encapsulate links to javascript and css inside tags without actually having to include the CSS and JS "in-line" with the rest of the content. All you have to do is create a link to the file.
Example:
{script type="text/javascript" src="./js/fooscr...
Based on an answer I saw in this question: Link
I'm wondering, is this a safe thing to do?
Suppose I implement this and a page gets requested that has a couple of JS and CSS files linked to it. Are the textfiles simply sent or does the server first parse them? Don't have a server to test it right now.
Also, is this a common method of ...