for($i=0;$i<$num;$i++) {
if($i==even) $hilite="hilite";
dothing($i,$hilite);
}
This is basically what I want to accomplish.
What is the most efficient way to determine if $i is even?
I know I could check if half == mod 2 ... but that seems a little excessive on the calculations? Is there a simpler way?
...
Hi, i need to remove all email addresses and links from a string and replace them with "[removed]" and i'm a bit lost on how to do it.
Can someone help me on this?
Thanks.
...
Hello! I have a PHP web app that generates a somewhat complex report from our database. The resulting data structure to populate the report is a big ol' array, and it's heavily nested, and it's kind of a pain to dig into to find just one thing.
Ideally I'd like to have some kind of data structure that I can just query, like a database....
I have an multi dimensional array:
$array[0] = array ( name => "Bob",
position => "Chair",
email => "[email protected]"
);
$array[1] = array ( name => "Al",
position => "",
email => "[email protected]"
);
//etc..
I want to sort it so that those whose position != "" are first, then the rest alphabetically by name... I'm not very fam...
Hello,
I am working with a script for resizing images. I seem to be getting an error:
Error: no image was specified
Probably because of this code in the script(image.php):
if (!isset($_GET['image']))
{
header('HTTP/1.1 400 Bad Request');
echo 'Error: no image was specified';
exit();
}
Here is what I...
I have 2 tables items and item_relations
items has 4 columns row_id(primary key), story_id, field1 and field2
item_relation stores the relation between each rows in items table it has 2 columns parent_story_id and child_story_id. Both columns store story_id's of rows from items.
A parent item can have many child items and a Child can ...
We have a variable with hmtl code inside.
<?php echo $list; ?>
This will give something like:
<li><a href='http://site.com/2010/' title='2010'>2010</a></li>
<li><a href='http://site.com/2009/' title='2009'>2009</a></li>
<li><a href='http://site.com/2008/' title='2008'>2008</a></li>
Want to add class for each <li>, it can be taken f...
Hi guys!
can you help me to build a form that return whois result from whois.com in PHP.
I had an old way, but it is not working anymore!
Thanx
...
This is what I have: All objects that can be persisted on the database extend the DatabaseObject abstract class, which has all the logic code to actually watch for attribute changes and run the databas queries.
I'm using two static variables to define object-specific details. I define them generically in the base class, and then suppose...
I am using Team Foundation Server 2010 as source control with Visual Studio 2010 and VS.PHP. I have set up a Deploy.xaml workflow to execute upon check-in. All this needs to do is export the changed files to a test server. I cannot find any documentation on how to build this simple task through the GUI. Can anyone point me in the right d...
I was intrigued by this discussion of image scaling and subsequently found out that the PHP code I'm using to create thumbnails from uploaded images suffers from the same problem. I decided to try the PHP fix posted near the bottom (converting gamma from 2.2 to 1.0, resizing the image, converting gamma back from 1.0 to 2.2). This works t...
I have lots of code snippets on my pc that do a whole bunch of cool things in C# (not asp.net, these are mainly console apps). I store all my results in a mysql database on my home PC.
What is the best way forward for converting this all into an online web service with login portal etc? My asp.net knowledge is limited, so I may have to ...
I have a url formatted like this:
http://www.example.com/detail/state-1/county-2/street-3
What I'd like to do is parse out the values for state (1), county (2), and street (3).
I could do this using a combination of substr(), strpos(), and a loop. But I think using a regex would be faster however I'm not sure what my regex would be. ...
Hey All
I need to check if a file exists but I don't know the extension.
IE I would like to do:
if(file_exists('./uploads/filename')):
// do something
endif;
Of course that wont work as it has no extension. the extension will be either jpg, jpeg, png, gif
Any ideas of a way of doing this without doing a loop ?
Thanks in advance...
What I ended up doing was taking two SQL queries and using the array_intersect() in PHP to filter out the results:
$sql1 = 'SELECT z.*, u.username, u.user_colour, u.username_clean, u.user_avatar, u.user_avatar_type
FROM ' . ZEBRA_TABLE . ' z, ' . USERS_TABLE . ' u
WHERE (( z.user_id = ' . $user->data['user_id'] . '
AND z...
I'm looking for a way to filter and control access to a folder on a website.
However, what I'd like to do is filter the access requests via PHP and Apache, a little like the way filters are implemented in Java.
So, when a user tries to visit
http://www.mywebsite.example/files/afile.zip
I'd like it first to pass through a PHP script t...
I have read many posts about setting up unit testing in Zend Framework and I simply have not been able to get even one simple unit test to run. The issue is with setting up and testing the bootstrap environment. I tried the simplest of ways using the ZFW docs, but I always get this error:
Zend_Config_Exception: parse_ini_file(/usr/l...
Hi.
How can i start javascript via ajax ?
html file
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>FusionCharts 3.0 Dashboard</title>
<script language="JavaScript" src="../FusionCharts.js"></script>
<script language="JavaScript" src="../PowerMap.js"></script>
<script type="text/javascri...
Here's where I've been:
I made a PHP client call via soap to retrieve an array of data,
I successfully receieved and converted my array to JSON via json_encode,
I then echoed it back to my page.
Here's where I am:
I get back my array in this format...
{"MethodName":"ID,11|1|Item1,22|2|Item2,33|3|Item3"}
Here's where I want to be:
Using...
The Amazon AWS SQS WSDL (at https://sqs.us-east-1.amazonaws.com/doc/2009-02-01/QueueService.wsdl) lists multiple "ports" with different "addresses" (near the bottom of the file), which specify the HTTP and HTTPS addresses for the service.
Using the PHP SOAP object:
$aws_ns = 'http://security.amazonaws.com/doc/2007-01-01/';
$sc = new So...