Jump to content

salathe

Staff Alumni
  • Posts

    1,832
  • Joined

  • Last visited

  • Days Won

    3

Everything posted by salathe

  1. You don't need that second line.
  2. I did the same, only with slightly less (8px) padding and a number of other tweaks (like removing the header entirely). It was difficult to scan the thread list otherwise.
  3. You could use one of the Ctype[1] functions (ctype_digit), a Filter[2], is_numeric[3] to name a few different approaches. 1. http://php.net/ctype 2. http://php.net/filter and http://php.net/filter.filters.validate 3. http://php.net/is_numeric
  4. Or, to save a temporary variable, pathinfo($_FILES['uploadedfile']['name'], PATHINFO_EXTENSION) See http://php.net/pathinfo for details.
  5. Looks great, thanks Daniel. [ot] Now I can go off on long, rambling tangential discussions without fear of the OP thinking all of this stuff is directly relevant to their individual post! Yay. [/ot]
  6. Any update on something like this? I know I've been not making (useful but) off-topic additions to posts recently because the off-topic comments all-too-often get mistaken for something more relevant to the topic than it might perhaps be. If we could make OT comments visually separated from the main discussion, that would be awesome. E.g.
  7. And there's no reason why you need to stop them anyway. If you think there is, you're missing the point.
  8. Since we're playing with SimpleXML, things aren't quite so simple (oh the irony). You'll have to pull out the products to an array, then sort that array on price (probably using usort as cags mentioned). You say that you've already tried to "convert to an array", that's a good starting point.
  9. There is a slight chance that the number generated by abazoskib will be 1000000 (i.e., 7 digits), to only ever get 6-digit numbers you'll need to call rand(100000, 999999).
  10. Also bear in mind that your pattern will allow anything (or nothing) before and after the date. As it stands, the value abc 2009-11-20 def will match (and your script will echo ok). For more info on what to do, take a peek at http://php.net/regexp.reference.circudollar and http://www.regular-expressions.info/anchors.html
  11. Can you do var_dump($test); ? If your code is the same as in the post above, its value will be 1997 and not the date that you think it is.
  12. That won't do the same thing, it only unsets the CNAME item (if there is one). You could do (with a named or anonymous function, whichever suits): function filter_no_cname($item) { return $item['type'] !== 'CNAME'; } $filtered = array_filter($array, 'filter_no_cname');
  13. Please be mindful when using rajivgonsalves's code, it may allow "pages" that you really don't want it to allow. For example, if the presented code was in index.php and the user requested index.php?p=index then the page would try to include itself again and again and again and again and again and again until the max. function nesting level is reached (~100). It also allows the accessing of any readable file on your server like /etc/passwd and if allow_url_include is On then someone could execute their PHP code within your script! If you are going to go with this approach, make sure to only allow accessing files in a specific directory (and sub-directories if you really need them) and be absolutely sure that the only files people can access are those that you want them to be able to.
  14. Why not just call preg_match_all() with a pattern that looks for something-that-looks-like-an-email ? I think your approach above is trying too hard to be complicated.
  15. *salathe rescues a scorched T-shirt from the fire pit
  16. Looking through lots and lots of string combinations will take a "huge time" to process, a lot of function calls are happening: for the example string above substr_count and substr will both be called 1134 times. A regex approach might be worth considering but might end up being a nightmare.
  17. If you're using PHP 5.3 look into date_diff (or DateTime::diff). If not, the user comments for that function might help.
  18. I feel so used. However, you'll have fun explaining things to whoever marks your homework. Don't forget to tell your teacher/tutor/professor how helpful and nice PHPFreaks people were.
  19. Here's one way, the process is to basically loop over the different sizes of character-combinations (from 2 to half of the subject string [you can't repeat more than half of the string without overlapping!]) and for each of those sizes loop over the different character-combinations of that length within the string. We can count the number of non-overlapping times that a chunk of the strings repeats (e.g. "kds" appears 8 times) with substr_count(). $subject = 'shdjssueeekdssdeewsdwkdskdskdsskadkdssdsadkdssadkds29skds'; $min_num = 8; $all_len = strlen($subject); // For each chunk length from 2 to half-of-string-length for ($i = 2, $max_len = floor($all_len / 2); $i <= $max_len; $i++) { // For each available offset in the subject string for ($offset = 0, $max_offset = $all_len - $i; $offset < $max_offset; $offset++) { // Get the chunk and count how often it occurs in the subject $chunk = substr($subject, $offset, $i); $count = substr_count($subject, $chunk); // Only record this chunk if it occurs at least $min_num times if ($count >= $min_num) { $repeats[$chunk] = $count; } } } // Sort values in decreasing order arsort($repeats); var_dump($repeats); /* array(3) { ["ds"]=> int(9) ["kds"]=> int( ["kd"]=> int( } */
  20. What exactly are you having trouble with? Do you understand what a "regex" is; what "validation" is; what an "email address" is?
  21. It sounds more like some Flash-related problem than anything requiring writing (and managing) multiple files.
  22. Why not try a whole bunch of different systems and see which works best for you? Personally, the main reason why I don't like (bad choice of words, subversion works and I do like it) subversion is because if I am "offline" (out and about, the server loses connectivity, wifi is off to save battery, whatever) then it makes life difficult because I can't commit changes. In those situation, with Git, my work flow isn't altered because I can commit changes locally without being online then let the remote server "catch up" (by pushing to it) when I do get online.
  23. I think the OP means why not how. First, it is important to note that print is not a function so may cause confusion when called like one! The parentheses in the example code above are meaningless and only serve to give the false impression that the line of code will behave like normal function calls. When PHP evaluates the following line: echo print('3').'2'.print('4'); It might as well be: echo print '3' . '2' . print '4'; Both are identical. If we were to use parentheses to represent what is evaluated together it would look like: echo (print '3' . '2' . (print '4')); Working through this as PHP does: 1. Concatenate "3" with "2" to get "32" 2. Print "4" 3. Concatenate "32" with the return value from the second print (integer 1) to get "321" 4. Print "321" 5. Echo the return value from the first print (integer 1) so echo "1"
  24. salathe

    Salathe

    I'm on Sitepoint, but not TheRoot42. cags yes I had an interview and it went very well so we will see what happens from here.
×
×
  • 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.