Jump to content

Anti-Moronic

Members
  • Posts

    571
  • Joined

  • Last visited

Everything posted by Anti-Moronic

  1. DOH. Thanks. Really should learn my array functions!
  2. I have this array: Array ( [jan] => 2 [feb] => 1 [mar] => 2 [apr] => 1 ) ..and I want to return: Array ('jan', 'mar') As in, find the 2 elements with the highest count and put them in an array. What is the simplest way to achieve this?
  3. My friend, use jQuery instead. You will have an easier time. Even if you know little about javascript - start with jQuery. learn selectors or something. We'll need to some example html for the generated rows. Are you wanting to hide this info via AJAX or just using js like a 'quick hide' feature?
  4. Good example, but the trouble with that is if the draw() number exists it will generate another draw() number without verifying if that also exists. Would be better to define the numbers and have them removed from a number map so they cannot possibly re-occur. Of course, there may also be a better way..
  5. Say I have this array: array( 0 => time 1 => time 2 => to 3 => to 4 => to 5 => fly ); and 2 variables - $occMin and $occMax as number of occurrences. If: $occMin = 2; $occMax = 3; I want to produce sorted list with most occurrences at the top: array( 0 => array('to', 3), 1 => array('time', 2) ); My face just melted at the thought of even beginning to tackle this. Is this somewhat possible? would it require a monster function or am I missing some native php functions which could lend a hand?
  6. Thanks for the response. Strip tags only removes the tags and so would leave the link text still there. I need to remove all links or tags of a certain type and their content. That is why I would remove the links and text but not remove the content within the div. Thanks.
  7. Here is the text: <div class="left">Lorem Ipsum is simply dummy text of the printing and</div> typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scramble'd it to make-shift type <a href="google.com">specimen book</a> and something [tag]else[/tag]. Essentially what I'm trying to do is extract all of the words above while abiding by these rules: 1. word can contain dash and apostrophe (scramble'd and make-shift above) 2. word cannot be within a link tag 3. word cannot be within a block tag - [tag] 4. word cannot be part of a tag name or html (class in class=", div, a, tag etc) That's about it. Any advice on where I might start with that? I'm currently experimenting with it but all I have is this: (\s?)[a-zA-Z0-9\'\-]+(\s?|\,|\.) Shameful, I know.
  8. From my perspective, if it has code that I don't use then it is bloated. Yes, but bloated has a definition. It isn't opinion. Simple fact is: if you don't use a framework you're wasting time and losing money. If you build your own framework, unless it is for commercial reasons, you're learning, bu wasting time, and losing money. ON top of that, don't just walk into projects thinking you can use your own framework. Big clients understand the value in using a well known framework: pool of developers who are instantly qualified to make amendments. If you want less bloat, use a loosely coupled framework. Most modern frameworks are like this now - Zend Framework, Symfony2 as examples. Whatever you do, at least learn a framework I can have a blog built with admin capabilities, user registration, everything within 30 minutes by using a framework because I already have the module to plugin to that framework.
  9. There are pros and cons of using either. PHP will work regardless of the browser, PHP will likely be faster (but that doesn't mean it will *seem* faster to the client). This is important, although PHP will be parsed faster, it will not seem that way to the client if you, for example, use AJAX. If you use PHP to change some text on a page based on a value in a cookie, you really think that will be faster than using javascript to do the same thing? Not at all. JS will win in speed just because it is directly parsed by the browser in real time, even if the actual parsing takes longer. So, if you don't mind sacrificing some independence, use Javascript. Then if need be, use PHP as well. Don't forget, using PHP will also put stress on the server. Won't matter to most but when you're dealing with enterprise applications it is extremely important you don't waste resources processing something the browser can process.
  10. This is terrible. If you are developing a complex application/website, do yourself a favor and use a framework from the beginning. That will teach, almost enforce, best practice application design and coding standards. My advice: start again with a framework. Good frameworks: Zend Framework, and Symfony2 is a breeze to work with.
  11. Of course. There is no doubt about that. However, I'm looking at what is well designed in terms of plugins, regardless of the framework they are extending.
  12. I'm going to be tackling my first plugin soon and I'm looking for plugins which you feel are of very high quality, under the hood. Stuff I can use as an example while I design the framework for my plugin. Any ideas?
  13. Thanks Jay, I really appreciate your input but those are just examples. I could send over a 100 examples - the main thing I am trying to validate is point 2) above. For example, this should also match: 012-345-69 even: 0-1-2-3-4-5-6-9 or 0 1 2 3-4-5-6-9 String cannot begin or start with dash. after each number there can only be a dash, space or another number, and after each dash or space there cannot be another dash or space. Thanks again. I've validated based on specific examples, but as soon as I try to write one which matches all I get stuck.
  14. Thanks! Sadly, according to 2 your assumption would be incorrect. That is just an example of a match. A few more matches: 01-2-345 69 012 345 69 012345-69 This is the trouble I had. I am having to match based on each number and the adjacent character. Also, I cannot trim, this must run without trimming dashes. Any other ideas?
  15. What you should do is build in validation methods. Like: private function validConnection() { if($this->connection){ return true; } if($this->connection = mysql_connect($this->dbData['host'],$this->dbData['dbuser'],$this->dbData['dbpass'])){ if(mysql_select_db($this->dbData['dbname'],$this->connection)){ return true; } return false; } return false; } Then you use: if($this->validConnection()){ //do queries } ..which should be inside a query method. That way, you know if there are any connection problems, selecting db etc before you even attempt to run any queries. When you run your 'get()' method, you need to check for results before you start iterating over them. As a quick test, add this to your sql functions: mysql_select_db("oop") or die(mysql_error()) Same with mysql_query, and mysql_connect. Don't use this after you know the problem, have these errors stored in an array within your class, and output if you are debugging.
  16. I've have been trying for too long now to understand the regex required for this. I'd appreciate any help I can get. This should match: 012-345 69 However, these should not: -012345 678 01203- 34566 1234x567 This is validation is: 1) must not begin or end with dash (-), I have trimmed to ensure does not begin or end with space 2) each number may contain a dash or space in between - however, cannot contain any combination of the two in sequence. Like dash dash, dash space, space space, space dash 3) the only other characters which can be present in the number are dash and space. Any ideas?
  17. Actually..scratch that, there is some excellent documentation here: http://symfony.com/doc/2.0/book/index.html
  18. This is the problem. There are no tutorials as yet on SF2, and the documentation is lacking. You're going to have to grit your teeth and keep digging. It'll click eventually
  19. Using frameworks for web development is like using motorized transport to travel to work. Some people insist on walking, ie no framework. Some people insist on cycling, ie their own framework, others insist on using their car, ie a popular framework with their own twist, and others just know using the bus is the easiest, most reliable, cost-efficient solution: those are the people who use popular frameworks, and while their 'riding the bus' they have plenty of time to read the paper (study documentation). ..ok..complex and somewhat drawn-out and misdirected analogy but i'm feeling playful Point is, nearly every website you visit a framework is being used. Could be js (jQuery) or php...there is at least one framework being put to good use. For micro projects frameworks are usually overkill (the php kind) but there are even exceptions there. Use a framework, and don't look back.
  20. I know it is a preview release. But I have been working with symfony 1.4 since it's release. As I understand Symfony2 has been built largely from scratch. Does anybody have any advice? I have the choice right now to use ZF1 or Symfony2, whereas ZF1 looks more stable, it is also showing it's age and I can't see ZF2 on the horizon. What kind of risk would I be taking if I used Symfony2 for production? It is not a throwaway project, but I do have plenty of time to deal with a crisis should that occur. Is anybody else planning on using Symfony2 for a new project?
  21. Oh, I think I know what you mean. You want php to produce these bullets every 30 minutes, but not depend on a user to view a page? If so, you need to look into cron jobs.
  22. Without a doubt, use arrays. Performance is a non-issue in this regard. Worry about the performance of the developer working on the code! If you use individual variables like you have above, be prepared to manage one hell of a nightmare come refactoring time.
  23. I see what you mean. The budget is not a problem at all. In fact, I'm currently below budget so the additional work would be fine and fit in ok with the deadline. Another requirement for this rebuilding of the app is to make it more 'automated' so really a hands-off approach is better. I don't mean that by managing the site, I mean that by literally how the site functions. A custom admin panel will more than suffice. This is the problem I'm having. The changes are so drastic and the current Drupal app is such a mess that the only viable option is to start again. I guess in that respect I could have just asked Drupal Vs Zend Framework for complex websites. Thanks for the input. I'd welcome any other input as well.
×
×
  • 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.