I have an input for users where they are supposed to enter their phone number. The problem is that some people write their phone number with hyphens and spaces in them. I want to put the input trough a filter to remove such things and store only digits in my database.
I figured that I could do some str_replace() for the whitespaces and ...
Hello everybody,
I'm trying to connect to a beanstalkd server through a PHP script and to reserve jobs from an existing queue.
I'm using the fgets() function to get responses from the deamon, expecting the script to hang unless a job is available, here's a sample code:
set_time_limit(0);
$connection = fsockopen('localhost', 11300);
fwr...
How can I redirect in PHP with this setup below without getting header output errors, I understand that nothing can be printed to the browser before a header is set, I am looking for a solution, not an explanation of why it happens please.
<?PHP
// include header
include ('header.inc.php');
// In my body section file if this is a pag...
I am using a feed creator (specifically, Kohana's feed::create()), except some of my text might be like this in the description element
See code below
<?php echo 'example'; ?>
The feed creator is using the SimpleXML Library. Whenever the data is returned (using $xml->asXml()) the html angle brackets inside the description elem...
Is there a reliable way, using PHP, to determine if a request comes from the same host that the PHP script is hosted on? In other words, is there a way to determine if the client and server computer are the same?
...
I use the Exiv2 command line tool on Linux to edit image metadata like so:
exiv2 -M"set Iptc.Application2.Caption String This is my caption....." modify IMG.jpg
I want to execute this from PHP, using a caption provide by a user. This will work if the user enters no special characters:
exec('/usr/local/bin/exiv2 -M"set Iptc.Applicatio...
I have a couple of years as a PHP developer under my belt now, and I have to admit other web languages/frameworks (ASP .Net and Ruby on Rails especially) are looking much more tempting than PHP. It just seems like PHP is being left in the dust by the competition. I'm even seriously considering abandoning PHP altogether and going with R...
eg: existing data retrieve from db field: a,b,c,d,e
so now $data= "a,b,c,d,e";
eg: new data to be added--- cc, gg
final value saved into db will be $finaldatatobeupdatedintodb= "a,b,c,d,e,cc,gg";
Retrieve out and add in few more values.
Then append it back into the comma list.
How to do it purely with implode and explode, without nee...
I am looking for an algorithm that will take numbers or words and find all possible variations of them together and also let me define how many values to look for together.
Example lets say the string or array is:
cat
dog
fish
then the results for a value of 2 could be:
cat dog
cat fish
dog cat
dog fish
fish cat
fish dog
SO the r...
Using PHP, given a string such as: this is a <strong>string</strong>; I need a function to strip out ALL html tags so that the output is: this is a string. Any ideas? Thanks in advance.
...
How can I "reset" a namespace to the global one? Given the following code:
namespace foo;
include 'myfile.php';
myfile.php will now try to load all of its classes in the foo namespace, even though its classes are in the global namespace. Now it wouldn't be a big deal to swap the order of those lines, but how would I deal with myfile.p...
Hi guys,
I'm experiencing some problems with ob_* function when it runs as a cronjob:
<?php
function getLayout($file, $extract=array()) {
if (is_file($file)) {
if (count($extract) > 0) {
extract($extract);
}
ob_start();
include $file;
$contents = ob_get_contents();
ob_end_clean();
retur...
All,
Sorry - this is probably a very strange question.
I'm working on a Flash RIA. One of the things it does is call an ASP page (that resides on another domain) to retrieve some data.
However, that ASP page requires users to log-in to that site before they're allowed to call that ASP page.
So, my first attempt at getting this to wor...
Hello people,
I am successfully parsing an RSS feed with PHP, but want to return a message when the feed is empty. I have included the
PHP File here to show you what I want to achieve.
I'm looking for it to break or stop executing, but print a message and stop at the point highlighted.
Thanks for your assistance.
...
Hello all, I put together a very simple search engine based on an article un zend's website using fulltext. My understanding is that if a keyword scores 50% or more, this will be dropped. This is good, but I know my client is not going to like it. I know they expect some keywords to be shown within a search result.
My main problem is th...
Hi,
Sorry if this seems like an easy question, but I've started pulling hair out on this...
I have a XML file which looks like this...
<VAR VarNum="90">
<option>1</option>
</VAR>
I'm trying to get the VarNum.
So far I've been successful using the follow code to get the other information:
$xml=simplexml_load_file($file);
$option...
I am curious, is there a size limit on serialize in PHP. Would it be possible to serialize an array with 5,000 keys and values so it can be stored into a cache?
I am hoping to cache a users friend list on a social network site, the cache will need to be updated fairly often but it will need to be read almost every page load.
On a singl...
I have a page that is definitely not a form but I need to use some callback functions to load data from an external source and display (e.g. a list of buildings on campus and their accessibility information).
What I have a need for is a landing listing page (lists all the buildings) and a 'view individual building' page. Also, I have a ...
Is it possible to add a menu item from within hook_menu() directly to the primary-links menu instead of navigation where they like to reside by default?
...
I am refreshing myself on OOP with PHP and I saw an example of setting functions and/or variables as static. When and why would I set a variable/function to static? I've done other languages and don't really recall ever using static, I never found a real purpose to it. I know what it does but why not just use a variable instead?
...