
k0z
Members-
Posts
22 -
Joined
-
Last visited
Never
Profile Information
-
Gender
Not Telling
k0z's Achievements

Newbie (1/5)
0
Reputation
-
That's not *quite* correct, actually. If you look at the data: 1,2,28,29,30 The amount of numbers between the end of a month to 1 (with respect to months) can be a maximum of 3 (because february starts @ the 28th). Furthermore, the jump from e.g. 2 to 20, for e.g., is much greater. If there is a deviation of a number LARGER than 3, then it is obvious it should go through a simple krsort(); I'm aware that a much simpler solution would be to maintain the month - but currently, it's not an option.
-
With or without the warning, the returned data is still incorrect. It returns: array(4) { [1]=> string(3) "one" [30]=> string(6) "thirty" [2]=> string(3) "two" [3]=> string(5) "three" } when it should be 30, 1, 2, 3
-
Now receiving the error: Warning: uksort() [function.uksort]: Invalid comparison function
-
Tried your code: $myarray = array(1=>'test',30=>'test',2=>'test',3=>'test'); uksort($myarray, "strnatcmp"); var_dump($myarray); This should have returned the keys in order: 30,1,2,3 But it returned them in 1,2,3,30 ?
-
If i have an array of data (the values don't matter, only the keys), such as: $myArray[21] = 0; $myArray[22] = 0; $myArray[23] = 0; $myArray[25] = 0; $myArray[24] = 0; $myArray[26] = 0; Running a krsort() on this array turns it into: $myArray[26] $myArray[25] .. .. $myArray[21] The problem is, these keys represent days of the month. If I had an array of: $myArray[29] $myArray[28] $myArray[30] $myArray[2] $myArray[1] I'd actually want this to be turned into: (EDIT: SORRY, the below values should be reversed because this is KRSORT and not KSORT. THIS GOES FOR ALL OF THE FOLLOWING EXAMPLES) $myArray[28] $myArray[29] $myArray[30] $myArray[1] $myArray[2] To represent an actual month. In addition, the data might not roll over the next month, so the data could be exactly what the first example was. Obviously, different months have different lengths, so the data could potentially be: $myArray[28] $myArray[27] $myArray[1] $myArray[2] And this would need to be turned into: $myArray[27] $myArray[28] $myArray[1] $myArray[2] What would the easiest way to do this be? Thanks.
-
Perfect! changed to: $start = 'June 24th 2010'; $end = 'July 2nd 2010'; $current_date = date('Y-m-d',strtotime($start)); $end_date = date('Y-m-d',strtotime($end)); $array = array(); // an array for the dates while($current_date <= $end_date){ $array[] = date('j',strtotime($current_date)); $current_date = date('Y-m-d',strtotime($current_date . '+ 1 day')); } echo "<pre>",print_r($array,true),"</pre>"; And working nicely. Thanks for your help.
-
If I have two dates, e.g.: June 24th, July 2nd and i want to range between the values, would would be the easiest way to accomplish this? Obviously range(24,2) would not return the correct array. The correct values SHOULD be: array(24,25,26,27,28,29,30,1,2); Because different months have different lengths, this could pose an issue. E.g.: Feb 27, March 2nd should return: array(27,28,1,2); What would the easiest way to accomplish this be? Thanks.
-
If I have an array of data, like: $times = array(1, 2, 3, 5, 6, 7); How can I determine that the number 4 is missing? The $times array will only ever hold data numbering from 1 to 7. These numbers represent the day of the week (1 is Monday, 7 is Sunday). So, for example, $times might be: $times = array(2, 6); In the above case, I would need to determine that the numbers 1, 3, 4, 5, and 7 were missing. Ideally, the missing numbers would be entered into another array. Thanks in advance.
-
I modified your code, and I now have this: $a = explode('<a', $thestring); $lengthleft = 46 - strlen($a[0]); $text = preg_replace("/<a([^>]*)>([^<]{" . $lengthleft . "})([^<]*)<\/a>/", '<a\\1 title="\\2\\3">\\2</a>...', $thestring); Thanks for your help!
-
The ENTIRE length of the displayed text needs to be the 46 chars, otherwise it defeats the point of having the code. How would I make the truncated link PLUS the original text equal a total of 46 chars, while truncating the link itself if necessary? Thanks.
-
It really depends on the specs of the sql server, the strain already on the sql server, etc. Generally, converting resource intensive sql queries into being handled by php/text files helps greatly, but the contrary, not necessarily.. It also depends on the size of the query you wish to create, E.G. if you plan to use mysql's RAND() function, create a virtual table, etc. Also depends on the frequency of the query, and how resource intensive it is. Its worth converting.. but this is one of those cases where you simply need to test it to be able to know the output.
-
Hi, I have this text in a string: Joe has posted in <a href="xx">a topic</a> I need to truncate this code, so that it only contains a maximum of 46 characters. The problem is, I want to be able to truncate the contents of the link, while still maintaining the link. So for example if the string was: Joe has posted in <a href="xx">abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz</a> It would be able to truncate the whole thing to the 46 characters, but still maintain the link. So the above string woudl return something along the lines of ( i didn't actually count that characters ): Joe has posted in <a href="xx">abcdefghijklmnopqrstuvwxyzabcd</a>... What would the easiest way to do this be? Thanks for your time! EDIT: Note that the html itself should not count as part of the characters when counted. The actual LENGTH is just the text, so in the above example the actual displayed length of text would be: Joe has posted in abcdefghijklmnopqrstuvwxyzabcd ... That part would be the actual 46 chars. note again I didnt actually count that to 46 chars, just estimating.
-
What is the name of the column? Dont know what you mean here. I listed the names of the fields in the first post.
-
Edit: not sure how i can use that to make this work?
-
Lets say i have a table, and within this table i have the following Fields: Field 1: a Field 2: a_column Field 3: b Field 4: b_column Field 5: c Field 6: c_column The Fields without the _column on the end ONLY contain a numerical value 1-10, which represents what order they should display in. The Fields WITH _column on the end contain either "left" or "right", which determine which column (left or right) to display in. My question is, how can I determine which is which. So for example, if the Fields contained these values: Field 1: a = 1 Field 2: a_column = "left" Field 3: b = 1 Field 4: b_column = "right" Field 5: c = 2 Field 6: c_column = "right" How would I determine the following: Left column: First: a -- Right column: First: b second: c Thanks for your time.