Jump to content

silkfire

Members
  • Posts

    569
  • Joined

  • Last visited

Everything posted by silkfire

  1. What does this give you: var_dump(curl_getinfo($ch), curl_error($ch));
  2. How do I get a static variable dynamically? I'm trying this but getting the dreaded PAAMAYIM error: foreach($this->entity::$dialog_data as $property) { Should result in Company::$dialog_data because $this->entity contains the string 'Company'.
  3. Where did you get this code from? There are Excel libraries out there, why are you making your own binary functions??
  4. I tried to login with your credentials but it says that account has been blocked. Maybe already been busted?
  5. Decodes perfectly with PHP, are you sure you did it the right way?
  6. Nowadays I only visit this forum to read Jessica's brilliant replies to lazy coders =D
  7. As per KevinM1's statement, try to avoid both the global keyword and the array $GLOBALS. Sending a variable to a function or having it as part of a construct in a class is a much more reliable solution.
  8. Replace the line: $files[] = $values['files']; with $files = array_merge($files, $values['files']);
  9. Jessica's replies to lazy help seekers - priceless
  10. He wants a script that can retrieve a list (array) with all the members of a clan in Combat Arms.
  11. I just tried my code with an example date '08/01/2012' and it worked perfectly, Jessica
  12. Comparing dates is a rather simple task in PHP. In your case I would suggest something like this: $date1 = strtotime($date1); $date2 = strtotime($date2) if ($date2 > $date1) { // CODE }
  13. It's a good practice to let functions return something instead of echoing it out, because otherwise you lose the control of knowing where in the code execution the string will be echoed out.
  14. Yeah if you even bothered to look at the solution. Here's some code for you: function array_sum_parts($n,$t,$all=false) { $count_n = count($n); // how much fields are in that array? $count = pow(2,$count_n); // we need to do 2^fields calculations to test all possibilities # now i want to look at every number from 1 to $count, where the number is representing # the array and add up all array-elements which are at positions where my actual number # has a 1-bit # EXAMPLE: # $i = 1 in binary mode 1 = 01 i'll use ony the first array-element # $i = 10 in binary mode 10 = 1010 ill use the secont and the fourth array-element # and so on... the number of 1-bits is the amount of numbers used in that try for($i=1;$i<=$count;$i++){ // start calculating all possibilities $total=0; // sum of this try $anzahl=0; // counter for 1-bits in this try $k = $i; // store $i to another variable which can be changed during the loop for($j=0;$j<$count_n;$j++){ // loop trough array-elemnts $total+=($k%2)*$n[$j]; // add up if the corresponding bit of $i is 1 $anzahl+=($k%2); // add up the number of 1-bits $k=$k>>1; //bit-shift to the left for looking at the next bit in the next loop } if ($total==$t) { $loesung[$i] = $anzahl; // if sum of this try is the sum we are looking for, save this to an array (whith the number of 1-bits for sorting) if (!$all) { break; // if we're not looking for all solutions, make a break because the first one was found } } } asort($loesung); // sort all solutions by the amount of numbers used // formating the solutions to getting back the original array-keys (which shoud be the return-value) foreach($loesung as $val=>$anzahl) { $bit = strrev(decbin($val)); $total = 0; $ret_this = array(); for($j=0; $j < strlen($bit); $j++) { if ($bit[$j] == '1') { $ret_this[] = $j; } } $ret[]=$ret_this; } return $ret; } $x = array(1, 4, 17, -9); $y = 5; var_dump(array_pop(array_sum_parts($x, $y))); Result: array (size=2) 0 => int 0 1 => int 1
  15. Why didn't you say this in the first place. You're trying to solve a classic problem - choose a certain number Y, and then let the algorithm find out which numbers from a list Z add up to and result in the number Y. Try this solution, the first answer: http://stackoverflow.com/questions/2667664/php-find-two-or-more-numbers-from-a-list-of-numbers-that-add-up-towards-a-given
  16. What exactly are you trying to achieve, i.e. for what purpose are you doing this?
  17. var_dump($cat_id) and see what you get?
  18. var_dump the variables $dat1 and $dat2 and see what you get back.
  19. I have this simple problem. How do I convert an array from this: array('item1', 'item2', 'item3'); to array( array('value' => 'item1'), array('value' => 'item2'), array('value' => 'item3') )
  20. You get this error because you're trying to assign properties to an object that hasn't been declared previously. Your best way to solve it is to create an empty object (stdClass) and then put as the value of its respective key. $slide_object = new stdClass; // Slide name if ($row->itemlink && $row->title) $slide_object->name = $row->title; //$row->name elseif ($row->menulink && $menuItem) $slide_object->name = $menuItem->name; //$row->name else $slide_object->name = $row->name; if (!$showName) $slide_object->name = ''; $output[$key] = $slide_object;
  21. Use the functions bin2hex() and hex2bin() for this. They were designed exactly for the purpose you need.
  22. Use the pow() function for powers: 23 = pow(2, 3) = 8
  23. silkfire

    Date

    fesan you have to try all possible locale strings until you're successful. The standard NO_no rarely works. "Norwegian (Bokmål)_Norway.1252" or "norwegian-nynorsk" or "no_NO.UTF-8" or setlocale(LC_ALL, 'no_NO.ISO8859-1', 'nb_NO.ISO-8859-1', 'no', 'nb', 'nob-NO', 'no_NO', 'nb_NO', 'nor', 'norwegian', 'bokmal'); ​Lycka till =)
  24. Make an empty array then add this to your code: $array[$entry->DrawnDate] = $file_name; This requires no date to be repeated (that is, each date must be unique).
×
×
  • 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.