-
Posts
5,717 -
Joined
-
Last visited
-
Days Won
6
Everything posted by Adam
-
One of my personal favorites. I invite you to share yours
-
In the words of Vinnie Jones in lock stock, "you cheeky barstard!"
-
Tested in IE7 now I'm home, works as well. Personally I wouldn't worry about it...
-
Which version? Tested in IE6 okay.
-
Meta cache preventions are inconsistent across browsers, try using PHP to set the headers: header('Cache-Control: no-cache'); header('Pragma: no-cache'); NB I wouldn't rely on JavaScript for anything "fail-safe".
-
Have a read.. http://www.w3.org/TR/CSS21/media.html
-
It's not recursive if that's what you meant, but it'll work on any 2 single-dimension arrays with equal length. Actually I didn't consider this originally, but it'll only work properly on integer indexes - converting literal indexes to integer in the event of them. I'd just go with Daniel's solution..
-
To make it more like shuffle() in-fact you could pass the array by reference: function shuffle2arrays(&$array1, &$array2) { if (count($array1) != count($array2)) { return false; } $count = count($array1); $keys = array_rand(range(0, ($count-1)), $count); $new_array1 = array(); $new_array2 = array(); for ($i = 0; $i < $count; $i++) { $new_array1[$i] = $array1[$keys[$i]]; $new_array2[$i] = $array2[$keys[$i]]; } $array1 = $new_array1; $array2 = $new_array2; return true; } Then you just need to call it with: shuffle2arrays($some_array, $another_array);
-
shuffle() is random so there's no way you can repeat it. However you could implement you're own shuffle method, for example: <?php function shuffle2arrays($array1, $array2) { if (count($array1) != count($array2)) { return false; } $count = count($array1); $keys = array_rand(range(0, ($count-1)), $count); $new_array1 = array(); $new_array2 = array(); for ($i = 0; $i < $count; $i++) { $new_array1[$i] = $array1[$keys[$i]]; $new_array2[$i] = $array2[$keys[$i]]; } return array($new_array1, $new_array2); } $array1 = array(1,2,3,4,5); $array2 = array('a','b','c','d','e'); list($array1, $array2) = shuffle2arrays($array1, $array2); print_r($array1); print_r($array2); ?> That's the only way I can think of doing it, someone else may have a much simpler solution though.
-
This is probably something the browser does automatically to save ink. Have you setup a print media style sheet?
-
How to get informed Clients Disconnected from the Server
Adam replied to llcoollasa's topic in PHP Coding Help
This may be of some use to you for Q1 (assuming a *nix system): http://www.mydigitallife.info/2007/12/13/how-to-find-and-check-number-of-connections-to-a-server/ You should be able to run that through the system function: system("netstat -plan|grep :80|awk {'print $5'}|cut -d: -f 1|sort|uniq -c|sort -nk 1"); You may not get a truly accurate result running through PHP though as you're not root user. Think you need to give more details for Q2, what kind of "message" do you mean? -
I've never implemented it myself but this may be of use to you: jQuery's stop() method.
-
Make website addresses into hyperlinks within a variable
Adam replied to mmsolutions's topic in PHP Coding Help
The ereg* functions are deprecated as of PHP5-3. I'd go with a preg_* solution if I were you. -
You can use empty to check if the variable is empty: <p class="right"><?php if (!empty($price4)) echo $price4 . " per Lb."; ?></p>
-
... and the error is? By the looks of things you're using undeclared variables -- or do you have register globals enabled? (bad idea)
-
PLEASE HELP! Order form not alerting user if they have error.....
Adam replied to ShadowIce's topic in PHP Coding Help
*slaps forehead* That'll be why var_dump had no output. Nice spot Buddski! You just need to change the form action as Buddski was talking about. Change: <FORM ACTION="page2.php" method=post> To: <form action="Orderform.php" method="post"> You also need to re-think the way you're testing if the form validation was successful. if (!(VerifyForm($formValues, $formErrors)) [...] Returning the $error array length will lead to this evaluating to true when the function returns 0 errors, because 0 == false. Instead return from the VerifyForm() function like this: if (count($errors) > 0) { return false; } return true; -
PLEASE HELP! Order form not alerting user if they have error.....
Adam replied to ShadowIce's topic in PHP Coding Help
By nothing do you mean "bool(false)"? -
PLEASE HELP! Order form not alerting user if they have error.....
Adam replied to ShadowIce's topic in PHP Coding Help
There's several problems then. Keep that last bit as what I just said or the VerifyForm() function will always return 0. I can only think there's a problem with your form logic, try a var_dump on the $errors array just before you return it. -
PLEASE HELP! Order form not alerting user if they have error.....
Adam replied to ShadowIce's topic in PHP Coding Help
Think this is your problem: return (count($errors) == 0); Try just: return count($errors); -
Which are lines 53 and 56? That looks like some messy logic.. What is it you're trying to do?
-
Make website addresses into hyperlinks within a variable
Adam replied to mmsolutions's topic in PHP Coding Help
You'd want to use regexp for something like this. This may be helpful: preg_replace('\b(https?|ftp|file)://[-A-Z0-9+&@#/%?=~_|!:,.;]*[-A-Z0-9+&@#/%=~_|]', '<a href="\0">\0</a>', $text); Taken from: http://www.roscripts.com/PHP_regular_expressions_examples-136.html -- not tested. Read up on preg_replace for how to use it properly. -
PLEASE HELP! Order form not alerting user if they have error.....
Adam replied to ShadowIce's topic in PHP Coding Help
Could you post just the relevant code? -
how to change background color using php variable
Adam replied to ethereal1m's topic in PHP Coding Help
Notice the red "deprecated" warnings on the BODY attributes: http://www.w3schools.com/tags/tag_body.asp As gwolgamott was saying you should use the style attribute, or better yet a CSS class: body { background-color: <?php echo $bg; ?>; color: <?php echo $fg; ?>; } And you were actually combining the two: <?php= .. -
Over how much time?
-