Jump to content

.josh

Staff Alumni
  • Posts

    14,780
  • Joined

  • Last visited

  • Days Won

    43

Everything posted by .josh

  1. if (substr($variable,0,1) == "M") { // do something }
  2. if you want to keep it as a string, you can do $string = preg_replace('~.*?(<img[^>]*>).*~is','$1',$string); or if you want to just retrieve all image tags and have them in an array, you can do preg_match_all('~<img[^>]*>~i',$string,$images); // image tags stored in $images array and on that note, you should be using the pcre functions (preg_xxx) instead of the posix functions (ereg_xxx) as the posix functions are deprecated.
  3. you're missing the and what about coming up with one that represents touché
  4. No. Class names (and functions) are not parsed inside quotes like that. Only variables arrays and objects.
  5. That's not an example of of a string being interpreted as a class name. That's an example of storing a string of value "Test" to a variable $testClassName. If you want to reference a static method like that, you can do Test::doSomething(); or else like $testClassName = "Test"; eval($testClassName."::doSomething();");
  6. // reference of class "Test" $testClassName = "Test"; $testClassName is not an object. It's a variable, and you're assigning a regular string to it.
  7. OP: is there some set list of "work" categories somewhere? Are those 4 the only ones?
  8. If $list is a string you can explode by the comma and follow prev posts or leave as string and do this: $list = preg_replace('~((?:[^,]*,){4})~','$1<br/>',$list);
  9. Yeah my bad, I typoed that before when I was testing and fixed it but forgot to update my c/p of it. putting work in the order by will order the work names, so they appear in the same order. without the work in the order by, the results might appear like this: [pre] total work name 4 oil change John Public 2 breaks John Public 2 tune up John Public 8 tune up John Private 1 breaks John Private 4 shocks John Private 6 oil change John Private [/pre] instead of this: [pre] total work name 2 breaks John Public 4 oil change John Public 2 tune up John Public 1 breaks John Private 6 oil change John Private 4 shocks John Private 8 tune up John Private [/pre]
  10. this query: select count(work) as total, work, name from tablename group by work order by name, work should produce something like this: [pre] total work name 2 breaks John Public 4 oil change John Public 2 tune up John Public 1 breaks John Private 6 oil change John Private 4 shocks John Private 8 tune up John Private [/pre] I would start out by assigning the info to a multi-dim array where first level is customer's name, 2nd level is work, like so: while ($info = mysql_fetch_assoc($result)) { $customers[$info['name']][$info['work']] = $info['total']; } As Mj mentioned, since not all customers will have all services, you can't do a simple nested foreach. But what you can do is a foreach for customers and then name each service explicitly. Or you can redo the while loop to auto fill in the gaps and then do a nested foreach. Throw in an array_sum() for the grand total.
  11. or you could have it in its own file and in your script include or require it.
  12. Well sure, WMM doesn't have a lot of stuff. Point though was that you could accomplish making those videos with WMM. I definitely agree that you should go for something better, as far as making movies better than those.
  13. You can populate a hidden field in a form and submit it to a php script that inserts it, or use AJAX.
  14. php automatically creates numerical keys. It uses the next available number, based on the last one created, if no key is specified. Since you made the first one 1, the next one will be 2, etc..if you do not specify any, it starts at 0. There are a couple "shortcuts" to array creation, but not for months of the year. For example, you can use range to auto-create an array with values as a range of numbers (or letters). In this situation, single vs. double quotes do not matter. The difference between single and double quotes is that php treats single quoted values as a literal string (it does not parse it), and double quoted values as something to be parsed (It will parse variables and shortcut char classes inside double quotes. Example: $foo = "bar"; $string = '$foo \n'; echo $string; // will output a literal dollar sign, foo and a literal backslash and n $string = "$foo \n"; //will output bar and a newline
  15. http://www.phpfreaks.com/tutorial/php-basic-database-handling
  16. stupid question, but are you sure it's not just the underline from a default link styling that's making it look like there's no underscore?
  17. Yeah over here you get this form with entries in and when you go in to fill out an application at a job you get someone (anyone) to sign off that you went there and filled out an app. I used to work in a temp agency office back in the day. Talked to the bums a lot. They said the govt. doesn't even audit those forms unless you're being a prick about getting your paycheck from them. Don't even look at it. Fill out blatant fictitious names in big bold letters for all they care.
  18. I guess I was wrong. That's what I get for doubting the built-in functions! I wrote a benchmark script to compare the two and it turns out str_word_count is roughly twice as fast as the regex.
  19. well I know for sure it's true for a for loop. Was thinking that also applied to a foreach loop as well. As far as regex vs. str_word_count being a bit more complex than that. Okay well then that would probably lean towards making the regex more efficient.
  20. or just cut the middleman out and use array_map class test { function one() { $t = array('one', 'two'); $t = array_map('strtolower',$t); } }
  21. Dunno how you guys do it over there but in the states you have to regularly report in proof that you are trying to get work, in order to get $$ from welfare, or even unemployment.
  22. D4rN n0 LEE+ 5P34k str_word_count() will not return that either. So if you want to include stuff like that, you'd have to regex it.
  23. "I'm not as rich as I'd like to be. Fuck, we must be in a recession!"
  24. ~((?:<br\s?/>\s*){3,})~is
  25. I'm going to sue women because they can have babies and I can't. Actually, that's not really the issue. The issue is that people treat me like I can't have babies as well as women, and that's just not fair.
×
×
  • 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.