php

php Replacing multiple spaces with a single space

I'm trying to replace multiple spaces with a single space. When I use ereg_replace, I get an error about it being deprecated. ereg_replace("[ \t\n\r]+", " ", $string); Is there an identical replacement for it. I need to replace multiple " " white spaces and multiple nbsp white spaces with a single white space. ...

What are the best places to learn regular expression (PHP)?

What are the best places to learn regular expression (PHP)? ...

PHP Form Return and Refresh

Looking at the previous implementation of a site that I'm working on, I can see that we have an options form that is calling a ManageObject.php script. That script does some actions on a number of objects, and then returns to the page via the following code: echo "<script type=\"text/javascript\"> window.history.back();</script>"; My ...

I would like to somehow sort this 'object_id' array so that i can get the relational values from the database

I have some information in my database like 'author' 'book', etc that are all related to a 'note_id', which is related to a 'user'. I query the DB for the note id. and i get thus back: *note_id assoc array* Array ( [0] => 32 ) Array ( [0] => 31 ) Array ( [0] => 33 ) Array ( [0] => 34 ) Array ( [0] => 35 ) Array ( [0] => 36 ) Array ( [0...

Kohana Controller Setup unexpectly slow.

I am a fairly experienced PHP developer, who is new to kohana. I have built a website with Kohana, but after I uploaded to my server, I found part "Controller Setup" is unusually slow, took over 12s, whilst other take less than 0.5s, Kohana Loading 0.014 1 0.49MB Environment Setup 0.004 1 0.05MB System Initialization 0.007...

Is it good to store dynamically created file's paths in database ?

HI This is in reference with my earlier question http://stackoverflow.com/questions/2361723/how-to-organize-files-created-dynamically-using-php I edited the question , with one more aspect, that is storing paths in to the DB.are there any advantages or disadvantages of doing this ? ...

GET Variable Problem

Hello, The table below works well. However, I am trying to pass $row["username"] along as a GET variable on the second hyperlink (the hyperlink in the second row that is class "sitename2" below). When I hover over this hyperlink, everything is blank after the "profile="... there is no $row["username"] to be passed along. Any idea why...

Dynamically create form elements with php

This short program is suppose find the column names of a table X, and create a form with at least one text field and one select element that contains all the names of the columns of the table. With that information, the user can perform a search on this table and further specify on which column he would like to do the search. I would lik...

Am i doing this wrong. Convert array to array value.

I am trying to convert an array to its value. I am getting this: Warning: array_values() expects parameter 1 to be array, string given in C:\xampp\htdocs\ReadNotes\mynote.php on line 42 Array ( [0] => 31 ) Warning: array_values() expects parameter 1 to be array, string given in C:\xampp\htdocs\ReadNotes\mynote.php on line 42 Array ( ...

how to provide print option in php

Hi In my view page i have to provide print option that prints the page ..I am looking for some examples or link that can help me can anyone provide some link ...

trying to backup mysql database using php

I got this code from this site: http://www.php-mysql-tutorial.com/wikis/mysql-tutorials/using-php-to-backup-mysql-databases.aspx But I'm just a beginner so I don't know what the config.php and opendb.php suppose to mean. Do I have to create those 2 files in order for this code to work? If yes, then how do I create it, it isn't included...

What date/time functions to use for PHP 5.2

The DateTime, DateInterval etc. classes are not available at the server I am using (PHP 5.2) Which functions should I use instead? ...

Improve my Search engine

Hello all! I have tried to implement a simple search engine for my application. This is what I have done: CREATE FULLTEXT INDEX item_name_other_name_desc_index ON item (name,other_name,description) public static function Search($string) { $delims = ',.; '; $word = strtok($string,$delims); while($word) ...

CakePHP recommendation to iterate a huge table and generate a sitemap?

I'm trying to create an XML sitemap using CakePHP, from a table which has more than 50,000 records at the moment, each record equivalent to a URI in the sitemap. Now the problem I'm facing is CakePHP is running me out of memory while generating it, for two reasons: A find('all') is building a huge associative array of the entire set of...

Problem logging out user using Facebook Connect and the official PHP API

I'm going to try and distill what's happening down to as little as possible, but still give you all the relevant code. It shouldn't make a difference, but I'm using the Zend Framework. This code executes if the user is not logged in, it fires in a PreDispatch controller plugin: Zend_Loader::loadClass('Users'); $users = new Users(Zend_...

Regular expression for checking any word of at least one letter

Regular expression for checking any word of at least one letter examples: fish (right) fish12 (right) 123 (wrong) T (right) 12n(right) ...

PHP accelerators and static fields.

Hi all! I would like to know about static (class) field representation within PHP interpreter. For example, when you load a class in Java, static fields will be associated with that Class object; that means two applications running same JVM (and same classloader) will have some kind of shared global variable ;) I'm just wondering, if ...

Use HTML Tidy executable with php, instead of compling

I have an application in php that is intended for shared hosting. So, I am going to have a hard time always getting html tidy compiled, since the hosts will vary, and what they provide will vary. Is it possible to just include the tidy executable in with my php application, and somehow, pipe html through that for cleaning? I am just l...

Customizing joomla search result page layout

The joomla search results appear on the home page. I want it to show up on a new page. According to some online posts I had to modify the mod_search.php to set the item id to a non existing item so i set it to 0, but the problem is that the changes are not being reflected in my search module at all. I also tried putting a hidden field ca...

PHP: filtering 2 dimensional array / multidimensional array

hi all, i need help on filtering my 2 dimensional array such as example below: array(29) { [0]=> array(2) { [0]=> string(16) "Andorra La Vella" [1]=> string(2) "AD" } [1]=> array(2) { [0]=> string(16) "Andorra La Vella" [1]=> string(2) "AD" } [2]=> array(2) { [0]=...