Jump to content

EchoFool

Members
  • Posts

    1,074
  • Joined

  • Last visited

Everything posted by EchoFool

  1. I thought of using this but thought - surely the for loop wouldn't loop if it was not set anyway because it only loops whilst it is set no ?
  2. Hey I have an array comparison which returns values in an array but then i need to change values that are 1 in the array to 14 so currently i use a loop but i get undefined offset issues. How can i change it to work properly with error? This is my current attempt: $HC = array_diff($Values,$Temp); $i = 0; foreach($HC as $value) { if($HC[$i] == 1) { $HC[$i] = 14; } $i++; }
  3. Hey, I am using array diff to find numbers in one array that are not in another array. Yet it returns a value which is in another array which is annoying... my array structure is: Array( [0] => 06 [1] => 11) //this is TEMP Array( [0] => 2 [1] => 3 [2] => 5 [3] => 6 [4] => 6 [5] => 11 [6] => 11)//this is VALUES Now my returned difference should be: [0] => 2 [1] => 3 [2] => 5 // all numbers not in TEMP But i get: Array( [0] => 2 [1] => 3 [2] => 5 [3] => 6 [4] => 6)//6 IS in TEMP and should not appear 6 should not appear but it does....any one know why ? This is my code: $Temp = explode('+',$HandValue); $HighCard = array_diff($Values, $Temp); Any ideas?
  4. Thanks will play around with it and see what i get!
  5. Hey, I have an array which stores a bunch of numbers lets say: [0] = 1[1] = 6 Now a second array has: [0] = 5 [1] = 6 What im trying to do - is find the first highest number from the second array that is not found in the first array.Both arrays are sorted already by the way using sort(). What is the best way to do this?
  6. Hey, If i have a string which contains numbers and symbols... such as 1:2:4 (its not always : for the symbol it changes) Is there a function that can convert the numbers that are 9 or less to have a 0 infront of them such as: 01:02:04 (also this is not timestamp format - just normal strings)
  7. If there are matching field names i just rename them: SELECT *,table1.UserID AS Table1UserID,table2.UserID AS Table2UserID FROM table1 LEFT JOIN table2 ON table1.id=table2.id All the uniquely named fields will be fine in the * symbol. This is just an example
  8. Hey - well the highest number is 14. Okay so adding 01 02 03 etc will solve my problem ? Will give it a try thank you!
  9. Hey, I have a bunch of fields with unusual strings of numbers seperated by symbols (used for php explode stuff at later parts of my script)... But i was wondering if there is a way mysql can order the data even though they are invalid integers/decimals. The values are like this: But i need them to order by DESC by comparing the numbers going from left to right (in a way - ignoring the : and the + symbols)How is this done?
  10. Hey, I've been working on a script to match playing card hands in a poker game against the river to return what the hand the user has and who won against other players. The problem is how do i approach an algorithm to do this in the first place. Cards are stored and structured by 2 characters seperated by a full stop. Example - 2 of diamonds and 3 of clubs is: D.2,C.3 now imagine a line of 5 cards (the river) and im trying to work out what they have and return the answer such as: 2 pairs or royal flush etc I so far decided my easiest way is to explode on the comma to get each card - then explode a second time on the full stop to get the suit and value into different variables. How ever - after that point im lost how i can do this up against the river to check what hand the user has. Any one got any tips on the best approach ?
  11. Good thinking! Im surprised i didn't think of that!
  12. I agree with PFMaBiSmAd And to further confirm these things you should have a error reporting on so it would say something is not set.
  13. Thanks CV i will use your function! Great stuff!
  14. Hey, I have a word filter which is dectecting strings that are only embedded in words. Which i don't want it to do. For example: If i want to filter "FR" and some one puts france - it flags it because france contains FR. How do i make it only look for "FR" on its own seperated from a word instead of it flagging nearly all words with the two letters together? Heres my filter: $text = 'testing'; //this should not return 1 // fill this array with the bad words you want to filter and their replacements $bads = array ("test"); foreach($bads as $key => $search_needle) { if(stristr($text, $search_needle) == TRUE) { return(1); break; } }
  15. Works a treat thanks sooo much !
  16. Hey Im trying to check a table of fields to see how many of those fields have different values. I tried it by using FieldName!=FieldName but it always returns the same answer of zero even if there is different values in different rows. This is my query: SELECT Count(UserID) AS Total FROM users WHERE Age!=Age AND `In`='1' AND TableID='".$row['TableID']."' Table: User | Age | TableID 2 | 20 | 2 1 | 22 | 2 From the above table there are 2 rows that do not match for AGE - but my query always returns 0. Any ideas? Hope you can help!
  17. Im really stuck here. I have an array that stores a number of seats from 1 to 8 that are currently booked at a table that is circular. So im trying to make a function to return the next "taken" seat at this round table to the "left" of where your sitting. How ever the problem i face is when you reach checking seat 8 you need to go to seat 1 as that would be "left" of seat 8. From the array below if i was sat at seat 7 i would need it to then check 8 and then back to one as this would technically be "left" of seat 8 at a round table. Here is an array example of seats that are already taken: [0] = 2 [1] = 3 [2] = 5 [3] = 7 How on earth do i do it - i can't even think of the logic on this one :S
  18. Hmm now i get: I set the tables then to : users t1 and users t2 but same problem exists. Any ideas?
  19. Oh okay thanks for the tip i will edit it soon and let you know! Thanks
  20. Okay i tried but i get an error... heres my query: SELECT COUNT(UserID) AS Valid,SeatPosition FROM users WHERE TableID='2' AND SeatPosition > $MyCurrentSeatPosition ORDER BY SeatPosition UNION SELECT SeatPosition + 8 AS SeatPosition FROM users WHERE TableID='2' AND SeatPosition <= $MyCurrentSeatPosition ORDER BY SeatPosition LIMIT 1 My Error:
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.