I have to check the buffer input to a PHP socket server as fast as possible. To do so, I need to know if the input message $buffer contains any other character(s) than the following: a-z, A-Z, 0-9, #, -, . and $
I'm currently using the following ereg function, but wonder if there are ways to optimize the speed. Should I maybe use a diff...
In PHP, you can initialize arrays with values quickly using the following notation:
$array = array("name" => "member 1", array("name" => "member 1.1") ) ....
is there any way to do this for STDClass objects?
I don't know any shorter way than the dreary
$object = new STDClass();
$object->member1 = "hello, I'm 1";
$object->member1->mem...
As far as I know, and have gathered from other SO posts, there are no proper tools for refactoring PHP code yet, so when it comes to refactoring, it's probably good old search-and-replace for most of us, with a good amount of praying that we didn't overlook something.
I would like to know whether there are any coding recommendations on...
I am trying to write a small php
application and i am facing a problem.
This is suppose to get text like :
this is *noun but it is *name.
And
should take the words that start with
a star and add them to the string
tokens. However this is not working.
// get list of fields (each should have words delimited by underscores
$storyArr...
I have this code and it should print labels with text boxes for people to fill in information. It takes a text like : $tokens = "*noun *noun *verb" and should print to the user a table that has :
Noun: (text box to be filled)
Noun: (text box to be filled)
verb: (text box to be filled) etc.
but it is not working
echo "<form action=\"st...
So I have fields that are generated dynamically in a different page and then their results should posted to story.php page. fields is going to be : *noun1 *noun2 *noun3 and story is going to be : somebody is doing *noun1 etc. What I want to do is to replace *noun1 in the story with the *noun, I have posted from the previous page ( I have...
Is the 'copy' of an array for a foreach (of php5, in this case) an immediate copy with actual overhead, or merely a lazy copy (copy on write) which only produces overhead if it detects a write manipulation?
The alternative, note in several places, is to run foreach over keys($array) -- how can that really be faster?
...
To dynamically fill DropDown controls on my HTML Form, I have written code that makes AJAX call to a .php file. This .php file populates the DropDown control with a single column value.
In this whole process, three files play the role.
(1) A HTML file that contains the entry form,
(2) A .js file containing basic AJAX code, and
(3) A .p...
I'm using a foreach loop to process a large set of items, unfortunately it's using alot of memory. (probably because It's doing a copy of the array).
Apparently there is a way to save some memory with the following code: $items = &$array;
Isn't it better to use for loops instead?
And is there a way to destroy each item as soon as they ...
Hello,
I'm interested about using 2 different classes in 2 different environment. Both classes should share the same structure (methods), but the one used in production would be "light", with less verifications or less funtionnality or different actions.
Example: a SQL query class which doesn't check the type/existence of fields.
Other...
I am not able to call a file: "fillDropDown.php". Why this code is not working?
function MakeRequest()
{
var xmlHttp = getXMLHttp();
try
{
xmlHttp.onreadystatechange = function()
{
if (xmlHttp.readyState == 4)
{
HandleResponse(xmlHttp.responseText);
}
}
xmlHttp.open("GET", "filldropdown.php",...
Hello!
I'm having some difficulties while trying to understand the whole zend routing concept. My scenario is to have a fallback controller for my small cms app. I've already implemented my own route class for this. What it does is, similar to module route, to try to check if the module from the given path does exists, if not my cms cont...
A few years ago I used to work with PHP and there've been many changes in PHP, especially on the OOP part.
Back then it was necessary to use the & operator at several places, especially when working with object instances (OOP was very rudimentary then) to avoid copying object instances.
With PHP 5.2 there seems to be a lot of improvem...
I have an Array like this (when I print_r). How can I sum all elements in this Array?
In this example, the sum is 0+1=1
Array ( [0] => Array ( [0] => 0 )
[1] => Array ( [0] => 1 ) )
...
I am doing shopping cart for my website
Storing purchase information in session
Storing purchase information in table.
Which is better solution? If I store it in table how and when will i delete the records in the table (i.e when not purchased by user but in table)
...
Currently, I need help with my loop. In each div, I want it to show two sets of FirstName and LastName instead of just one set, but I don't know how can I do that because of the loop. Also, the point of setting different font sizes is to create a visual look which is a funnel like shape. My question is, how can I add another set of name ...
This question is more of a "what is the best/easiest way to do this type of question. I would like to grab just the users id from a string such as <a href="/profile.php?rdc332738&id=123456&refid=22">User name</a> I would like to parse the string and get just the "123456" part of it.
I was thinking I could explode the string but...
Is php date() and time() function works between the years 1901-2038. What function will I use for my long based projects. or I am wrong?
...
How can I return a declared string like ( lastInsertId ) from my MySQL stored procedure and out? It's really annoying I can't return error messegts, complate messages and more out to my code in PHP5.
I hope somebody can help me here, I have search Google around without luck :(
Thanks to everybody.
...
I have a little problem with my script. When I try to run it I receive "Parse error: syntax error, unexpected T_STRING" as long as I have ' sign in my code. When I change all ' into " then I have the same error. So I have to change all " into '. How can I solve it?
Here is my code:
<?php
PutEnv(TNS_ADMIN='C:\Programy\OracleDevelo...