-
Posts
4,362 -
Joined
-
Last visited
-
Days Won
11
Everything posted by Zane
-
$return = $num; if($count >= 1) $return = Randomize::createRN(); else return $return; The main thing wrong with your code is your use of $repeat. It is never declared beforehand AND you never use it when you do declare it.
-
This is called a ternary statement. It's nothing more than if/else shorthand; whereas there is only one statement per clause. if($_GET['client'] != "") $client = $_GET['client']; else $client = "default"; include("somewebjpage?x=" . $client); is the same as $client = ($_GET["client"] != "") ? $_GET["client"] : "default"; include ("somewebjpage?x=" . $client);
-
What's the quickest most efficient way to change date format??
Zane replied to iPixel's topic in PHP Coding Help
yeah, the date() function date(strtotime("03-02-2011"), "d-M-Y"); -
are you calling it multiple times?
-
INNER JOIN communications ON records.IDNumber should be INNER JOIN communications ON communications.CommID
-
Possible to Remember the Last Created Random Number with PHP?
Zane replied to chaseman's topic in PHP Coding Help
Perhaps a ternary statement as well then. $_SESSION['x1'] = isset($_SESSION['x1']) ? $_SESSION['x1'] : random_number (); $_SESSION['x2'] = isset($_SESSION['x2']) ? $_SESSION['x2'] : random_number (); $_SESSION['op'] = isset($_SESSION['x3']) ? $_SESSION['x3'] : random_op (); -
Possible to Remember the Last Created Random Number with PHP?
Zane replied to chaseman's topic in PHP Coding Help
Try using sessions -
The last version I made should still be in the Staff Area somewhere as an attachment, if you need it.
-
mysql_pconnect() maybe?
-
So am I right in understanding that you are POSTing a users privileges to every page/script they go to? In other words, you're storing data that you need in multiple place, over and over again. Like they way verizon asks you to put your phone number before getting to a CSR, when you know for a fact of experience that they don't even use the number you entered. You should store your permissions in a session if you need them in so many functions/scripts. As for the array problem, I can't understand your elaboration.. why does it work "to a point"?
-
Here ya go. $array1 = array(500,503,9909,887,454) $array2 = array(100,223,200,109,500,503,9909, 787, 887,454); $array3 = array(223,200,109,500,503,9909); foreach($array1 as $v) { if(in_array($v, $array2)) { $findIt = array_search($v, $array2); unset($array2[$findIt]); } if(in_array($v, $array3)) { $findIt = array_search($v, $array3); unset($array3[$findIt]); } else $array3[] = $v; }
-
If you're sending an array through POST then you have to access it like an array For instance, you have a list of checkboxes in an array called checks[]. On your POSTED page you will have a variable called $_POST['checks'] You can access the elements of that array, just like you would any other array $_POST['checks'][0] == first checked value $_POST['checks'][1] == second checked value $_POST['checks'][2] == third checked value $_POST['checks'][3] == fourth checked value $_POST['checks'][4] == fifth checked value
-
obviously $value is an array what happens when you change all $value to $value[0] in the areas outlined for elements.
-
There is an algorithm called levenshtein which does exactly this... somewhat. What it does is give you "the minimal number of characters you have to replace, insert or delete to transform str1 into str2". Once you have this number, you can then compare it with the actual length of the string. So for instance, the levenshtein between "I eat food" and "I ate food" would be 3 (I believe). You would then take that number and divide it by the length of "I eat food".. AKA str1. 3/10 = 30-33% different. At least that's how I'd do it, I'm sure there are better ways.
-
When you set your file pointer $fp = fopen('text.txt','w'); That w at the end means.. Open for writing only; place the file pointer at the beginning of the file and truncate the file to zero length. If the file does not exist, attempt to create it. You want a... Open for writing only; place the file pointer at the end of the file. If the file does not exist, attempt to create it. This can all be found in the manual under fopen
-
The layout preview you supplied looks as if you're using Adblock...or something similar
-
There's always the ternary statement route document.getElementById(element).style.display = document.getElementById(element).style.display == 'block' ? "none" : "block";
-
There's really no way around it without implementing a registration system; even then, there would be some complex queries involved. Though still, that's the best route. Reason being, IPs can be changed and Cookies can be deleted... .. and well, Sessions speak for themselves.
-
Ah, wasn't thinking in terms of PHP, d'oh along with gizmola's solution you can use this ordinal function to get your 1st 2nd 3rd,etc functionality Straight from PHP.net manual http://www.php.net/manual/ro/function.is-numeric.php#99876 function ordinal($i='') { // a temporary value we can change, and keep the original value. $o=$i; // suffixes = 0th, 1st, 2nd, third == zeroth, first, second, third $s=array('th','st','nd','rd'); // if input just so happens to be a string, we check to make sure it // still holds a numeric value and only acquire the last 2 numbers. // if it's not a string, nor an integer, we freak out and say no. if(!is_int($o)) if(ctype_digit($o)) $o=(int)substr($o,-2,2); else return(false); // basically, if $o is between 11 and 19, we use 'th' // otherwise we use the last digit and if it's over // 4 then we use 0 (for the $s array index). return($i.$s[($o%100>10&&$o%100}
-
This topic has been moved to MySQL Help. http://www.phpfreaks.com/forums/index.php?topic=312470.0
-
Ok, I see now. I'm not too familiar with doing ranks like that, but I came across a tutorial that might help http://www.fromdual.ch/ranking-mysql-results
-
This topic has been moved to PHP Regex. http://www.phpfreaks.com/forums/index.php?topic=312460.0
-
What does your table structure look like.. and how are you calculating the percentages. Also, right off the bat, I can tell you the solution to this is that you need your percentage decimal to go to the farthest decimal place possible, in order to get an accurate ranking. Example... 2nd place == 99.86535758 3rd place == 99.86531115
-
It is possible to use serialize/unserialize to do this?
Zane replied to lopes_andre's topic in PHP Coding Help
you might want to utf8_decode BEFORE serializing foreach($array as $value) utf8_decode($value); $s_array = serialize($array); echo "", print_r($s_array), ""; -
Patience is a virtue.