php

Is there a VIM plugin that will show available functions from a class object in PHP?

for instance, say I create an object. $myobject = new MyClass; when I type $myobject->[I'd like a menu to pop up here with available functions] ...

Generating confirmation code for an email confirmation

Using PHP, what are some ways to generate a random confirmation code that can be stored in a DB and be used for email confirmation? I can't for the life of me think of a way to generate a unique number that can be generated from a user's profile. That way I can use a function to make the number small enough to be included in the URL (see...

jQuery + <a> tag

Hi All, I've created a Facebook/Twitter style status update where the new Status' get added to an unordered list. I now want to add a "REMOVE" function to it, however, I'm not sure how to best accomplish this. In my list item, create my [a] tag with the unique ID of the status post ID and set a listener class Have jQuery listen for [...

PHP Search array recursively and return count of index 'x' ?

Is there a PHP function that lets you search an array recursively and return the number of instances a certain key 'x' occurs (regardless of how deep)? ...

Loop through <div> elements using PHP

Hey I have a block of html in a string that is basically a list of divs... Each div has html inside that I want to parse seperately. I am having trouble figuring out exactly how to loop over the initial divs. Can anyone help? An example of the html: <div><!-- stuff in here --></div> <div><!-- stuff in here --></div> <div><!-- stuff ...

php loop with countdown

Say i start my counter at 400. How would i execute a foreach loop that will run backwards until 0? pseudocode $i = 400; foreach(**SOMETHING**)){ //do stuff $i--; } ...

I never really understood: what is CGI?

CGI is a Comman Gateway Interface. As the name says, it is a "common" gateway interface for everything. It is so trivial and naive from the name. I feel that I understood this and I felt this every time I encountered this word. But frankly, I didn't. I'm still confused. I am a PHP programmer. I did lot of web development. user (clien...

php and JSON help!

I have a script for updating a database table. I need to return a JSON array and to update some tables with JQUERY. my php script: $update = mysql_query("UPDATE PLD_SEARCHES SET STATUS = 1, TOTAL_RESULTS = ".$scrapper->getTotalResults().",RESULTS = $resultCounter WHERE ID = ".$searchId); $output = array("status"=>"COMPLETED","results"...

Size SKU in Magento

Hi, How can I allow SKU be longer than 34 characters (for simple products) for all products? When i add new product(simple) and enter more than 34 characters, Magento cuts it to 34 after saving. In the database the 'sku' attributes ( for quete item,order item,invoice item, shipment item) from eav_attribute table hold varchar(255). For...

picture is not refreshing in my browser

I am trying to upload a new picture in my webpage, but in the browser it is showing the old picture. When i check in the folder new image is being saved but it is not showing in the page. I tried to refresh but it is not helping me, shut down the browser still the same, tested in different browser still old image, Need help what can i do...

MySQLi equivalent of mysql_result() ?

I'm porting some old PHP code from mysql to MySQLi, and I've ran into a minor snag. Is there no equivalent to the old mysql_result() function? Because I can't find one anywhere in the documentation, here on Stack Overflow, or anywhere else with Google... I know mysql_result() is slower than the other functions when you're working with...

Splitting string into words with swedish chars

I'm trying to split a string with text into words by using the php-function preg_split. $words = preg_split('/\W/u',$text); It works fine except for swedish chars lite åäö. Doing utf8_encode or decode doesn't help either. My guess is that preg_split only works with single byte chars and that the swedish chars are multibyte. Is there a...

How do you format a 10 digit string into a phone number?

I have database records in the form of 10 character long strings, such as 4085551234. I wish to format these into this format: (408) 555-1234. I think this is regex related. I'm new to programming and completely self-taught here, so any sort of resource relating to performing text processing would be appreciated as well. Thanks! ...

Foreign Keys, question on relations

I've been toying with MySQL today and reading their documentation, gotten some handy information of optimization and a lot of things I didn't know. Now I've been adding foreign keys to my web application because it add constrains and I see it quite helpful. My doubt is, right now there is a Roles table and a Users table, I set a relati...

In an MVC approach, should I separate my model functions, or combine then as much as possible?

Should you separate model functions, even if they retrieve the fields of data? Lets say I have an Articles Model that gets Articles from the database. I have a function, getUserArticles($id), that gets the users articles. I have a function, getAllArticles($offset, $limit), that gets a list of articles. Should I leave the two functio...

PHP Markdown XSS Sanitizer

I'm looking for a simple PHP library that helps filter XSS vulnerabilities in PHP Markdown output. I.E. PHP Markdown will parse things such as: [XSS Vulnerability](javascript:alert('xss')) I've been doing some reading around and the best I've found on the subject here was this question. Although HTML Purifier looks like the best (nea...

Using <<<CON in PHP

What is the effect of the following code: $page = <<<CON <p><center>Blah blah blah</center></p> CON; What does the <<<CON do? ...

Write a .htaccess file in PHP?

On my PHP site I would like to sometimes show a maintenance page to users. I know I can do this in PHP very easily but I would rather use an htaccess file, I think performance may be better this way. So what I am wanting to know is can I modify a htaccess file in PHP? If it is possible I am thinking either, 1 - Have to files and 1 ...

Block user IP's with .htaccess or PHP?

From a performance only view, which would be the best way to block 30 IP addresses? A) .htaccess file or B) PHP code in the file ...

What is the most robust diff class/system/plugin for PHP?

I know of the Text_Diff PEAR package, but is there anything more robust? I'm looking to take diffs of strings with HTML tags in them, and I'd like to know the locations of all the differences including the tags. ...