I have an array like this
$sports = array(
'Softball - Counties',
'Softball - Eastern',
'Softball - North Harbour',
'Softball - South',
'Softball - Western'
);
and i would like to find the longest common part of the string
so in this instance, it would be 'Softball - ';
I am thinking that I would follow the this process
$i = 1;
// ...
I'm documenting the company framework for use with our default IDE (Netbeans).
It's normal that we send as params a new Object, like here:
$this->addControl(new TextControl('name', 'value'));
I could document the __construct() params at the normal place, but they aren't showed when you do a new <ctrl+space>.
So I tried to move this d...
Could you trim all $_POST vars? because i have a very long list right now for trim each var. looks very unprofessional. i thought trim($_POST); would maybe work but it didnt :]
...
At work we have to use a proxy to basically access port 80 for example, we have our own custom logins for each user.
My temporary workaround is using curl to basically login as myself through a proxy and access the external data I need.
Is there some sort of advanced php setting I can set so that internally whenever it tries to invoke ...
I am looking for a good class for logins. I don't need a login or registration form. Just the behind the scenes stuff mostly. Looking for recommendations.
...
Hi
Is there any way to set the selected item in a drop down box using the following 'type' code?
<select selected="<?php print($row[month]); ?>"><option value="Janurary">January</option><option value="February">February</option><option value="March">March</option><option value="April">April</option></select>
The database holds a month...
Hello, i need to make multiple calls to different web services using PHP and i was wondering if the php-java combination would be more appropriate in dealing with this issue.
The multiple calls to the services if called sequentially will create a significant amount of delay, so i am looking for ways to overcome that.
I have read arti...
I've got a site where someone searches for x product in their location and the site spits back a list of results.
if(isset($_POST['zip'])){
$qry="SELECT business_id FROM ".TBL_BUSINESS." WHERE zip LIKE '%".$_POST['zip']."%'";
$rs = mysql_query($qry);
$rec = array();
while(($row = mysql_fetch_array($rs)) !== FALSE ){
$rec[] = $row[0];...
I need to test the value returned by ini_get('memory_limit') and increase the memory limit if it is below a certain threshold, however this ini_get('memory_limit') call returns string values like '128M' rather than integers.
I know I can write a function to parse these strings (taking case and trailing 'B's into account) as I have writt...
What is the simplest ORM implementation around for PHP? I'm looking for something really simple and light (in terms of LOC, since speed it's not crucial I don't need caches and what not), preferably a single file or class package that doesn't depends on XML or other configuration files and it's easy to deploy.
Reading other similar ques...
If I have a string like this:
$str = "blah blah blah (a) (b) blah blah blah";
How can I regex so that the output is:
$str = "blah blah blah blah blah blah";
Needs to be able to support any number of bracket pairs inside a string.
Thanks for any answers!
...
Hi,
Does anyone know of a good function out there for filtering generic input from forms? Zend_Filter_input seems to require prior knowledge of the contents of the input and I'm concerned that using something like HTML Purifier will have a big performance impact.
What about something like : http://snipplr.com/view/1848/php--sacar-xss/
...
I'm trying to create an HMAC in Ruby and then verify it in PHP.
Ruby:
require 'openssl'
message = "A522EBF2-5083-484D-99D9-AA97CE49FC6C,1234567890,/api/comic/aWh62,GET"
key = "3D2143BD-6F86-449F-992C-65ADC97B968B"
hash = OpenSSL::HMAC.hexdigest('sha256', message, key)
p hash
PHP:
<?php
$message = "A522EBF2-5083-484D-99D9-AA...
I know this a common question but everything I found seems to remove white space.
I'm looking for a regular expression that will strip unprintable characters WITHOUT changing any whitespace. This a function that all user input will be filtered through, which means all the characters you could normally type on a keyboard are valid. Ex: t...
I am used to writing unit tests in Zend Framework 1.9 using PHPUnit_Framework_TestCase for my application.
Now I am trying to write a unit test based on Zend_Test_PHPUnit_ControllerTestCase by using the bootstrapping by Zend_Application of Zend Framework. But I am unable to get it running.
Here is my nonworking example:
class FamilyCo...
In C you can continue a string literal in the next line escaping the newline character:
char* p = "hello \
new line.";
( My C is a bit rusty and this could be non 100% accurate )
But in php, the backslash is taking literally:
$p = "hello \
new line.";
I.E. the backslash character forms part of the string.
Is there a way to get the C ...
Hi there
I execute 2 query's on 2 diffrend servers with the same table structure.
How can I merge the 2 Arrays in PHP?
Thanks
...
I'm working on implementing a way to allow HTML in a field that I have with PHP. The characters are saved to the database as they are inputted, so when I print them to the screen later on, I want the HTML to be respected (security is not an issue here, so please don't make it one). What I need right now is a way to change any " inst...
I'm trying to use the new PHP mysqli extension. I've got a function (safe()) that recursively uses mysql_real_escape_string to make strings safe. How do I use my mysqli connection inside this function to call the mysqli::escape_string() function?
Example:
$db = new mysqli($host,$user,$password,$database_name);
function safe ($data) {...
I have a POST request coming to one of my pages, here is a small segment:
[shipCountry] => United States
[status] => Accepted
[sku1] => test
[product1] => Test Product
[quantity1] => 1
[price1] => 0.00
This request can be any size, and each products name and quantity's key would come across as "productN" and "quantityN", where N is an...