Jump to content

.josh

Staff Alumni
  • Posts

    14,780
  • Joined

  • Last visited

  • Days Won

    43

Everything posted by .josh

  1. preg_match Would be the pcre equivalent. The patterns will pretty much be the same, only real difference is that the preg_xxx functions require an opening/closing delimiter in the pattern and modifiers (if needed) are specified after the closing delimiter. So for instance: ereg(".",$var1) would be preg_match("~.~",$var1) // ~ is used as the pattern delimiter. or for instance, eregi(".",$var1) // case in-sensitive would be preg_match("~.~i",$var1) // i modifier added to make it case in-sensitive
  2. $new = preg_replace('/([0-9])s/', '$1', $str);
  3. uh...you sure you posted this in the right thread? I don't see how this is relevant...
  4. This topic has been moved to PHP Freelancing. http://www.phpfreaks.com/forums/index.php?topic=311245.0
  5. Have you tried reading the manual that came with your wii, or going to the wii website and reading the manual there?
  6. ~^.*$~ would be a pattern for a full line. But you really don't need it.
  7. Here's my take, works (mostly) like preg_replace (same as first 3 params of preg_replace) but with an additional argument to specify how many to skip. function preg_replace_skip($pattern,$replace,$subject,$skip=0) { return preg_replace_callback( $pattern, create_function( '$m', 'static$s;$s++;return($s<='.$skip.')?$m[0]:"'.$replace.'";' ), $subject ); } // end preg_replace_skip Example 1: case sensitive, skip first match $pattern = '~test~'; $replacement = '[x]'; $subject = 'blah blah Testblah blahblah test test blah'; echo preg_replace_skip($pattern,$replacement,$subject,1); // before: blah blah Testblah blahblah test test blah // after: blah blah Testblah blahblah test [x] blah Example 2: case insensitive, skip first two matches $pattern = '~test~i'; $replacement = '[x]'; $subject = 'blah blah Testblah blahblah test test blah'; echo preg_replace_skip($pattern,$replacement,$subject,2); // before: blah blah Testblah blahblah test test blah // after: blah blah Testblah blahblah test [x] blah
  8. Oh silly me. And here I thought everybody was created equal. Thank you so much for setting me straight.
  9. reusable code is the core principle behind functions and, well, virtually all of object oriented programming.
  10. A game he was playing? From your own mouth he was trying to defend you trying to shortchange him. Not only are you a dick, but you don't respect your elders. And then there's the shag thread. Man...do you ANY morals? edit: And I just realized...you tried to shortchange him for $100, same as what you pay for shagging hookers.... what'd you do, have his payment in hand and decided to use some of it on another hooker? Then thought oh fuck, now I don't have enough to pay him, I know, I'm gonna try and cheat the old fart! geez man...you keep sayin' shit like this like you're all proud of it....do you not realize that nobody around here respects that sort of thing? Fucking grow up.
  11. Hehe ... I did that to an engineer who took too long to draw up plans, I when to my solicitor and requested he refund $100, he dug in and said it was my fault i didn't receive the supposed plans....anyhow it cost him over $2,000 defending it .....haha, typical commoners - too stupid to back down Wow man, what a dick move. How do you sleep at night? In the U.S. if someone sues you, the burden of proof is on them, not you. Innocent until proven guilty. Sure, the defendant has to spend money defending themselves, but if they win, they can countersue for what it cost them, court fees, lawyer fees, loss of wages, etc.. and they usually always win because they won the original case.
  12. .josh

    preg help

    ~{[^}]+}~ ~ starting delimiter { match a literal open curly brace [^}] negative character class meaning match anything that is not a closing curly brace + match one or more of the previous thing, so match one or more of anything that is not a closing curly brace. } match a literal closing curly brace ~ ending delimiter
  13. .josh

    preg help

    $string = "{PAGE_TITLE} - {PAGE_NAME}"; preg_match_all( '~{[^}]+}~', $string, $array); print_r($array); Array ( [0] => Array ( [0] => {PAGE_TITLE} [1] => {PAGE_NAME} ) )
  14. if (preg_match('~^([a-g]|h([a-e]))~i',$name)) { // matched }
  15. '~$x\s+=\s+$i\s+\+\s+$j;~' the overall point is to use \s+ to signify one or more whitespace chars.
  16. my guess is it's a template system of sorts, where people can define content and sub-content.
  17. I mean yeah true, if I were a small company trying to succeed in the market, of course I would be doing what I had to do to survive. I'm just sayin' though...I don't like how those smaller companies are spinning it off to the consumer that MS is evil and they are noble when it is clearly just a business strategy.
  18. it's because you are using a greedy quantifier (.+) so it matches all the way to the last instance of } instead of (.+) make it lazy by doing (.+?) or better yet, use a negative character class: ([^}]+) couple other things: preg_match() only matches first instance, I'm not 100% sure what you're trying to accomplish but you will probably want to change that to preg_match_all(). Also, after the preg_match you are using preg_split to further break down the values...but since you are just using | as a delim (a static delimiter) you should be better off just using explode for that bit.
  19. As it stands, things like OS's and browsers and well, virtually everything else on the user's computer, is ultimately the user's responsibility to learn and install and use. Forcing MS to package other browsers with their OS is not only unfair to MS, but it's unfair to the user. For MS it is unfair because IE is there solely because MS owns it. People have a hard time figuring out what's fair with MS because MS dips their fingers in a lot of things. The people who call foul for IE being prepackaged on Windows and not other browsers seem to forget that MS owns Windows. Since when should it be MS's responsibility to educate people on the internet, what it is, how to use it, choice of browser, etc..any more than them choosing which computer they bought or which OS it came with? How can someone claim that it's MS's responsibility to do that shit? Now, it's *probably* overall good business sense for MS to offer different browser choices pre-installed in their OS, and it's *probably* overall good business sense for them to educate, etc.. because it makes them look more transparent and hero-like. But that doesn't mean they should be forced to do it. To me this is the equivalent of a bunch of people coming to your house and you are forced by the govt. to have a selection of different colored plates for people to choose for their dinner. Or a defined list of various drinks for them to choose, as opposed to you as the host and owner of the house, getting to make that choice. Does it make sense to offer choices for your guests? Sure! Mark of a good host. Should it be required by law? No! Nobody forced them to come in the first place! So it is the same with users and computers and OSs and browsers. Nobody forced them to buy that computer or have Windows installed on it. That was the user's choice. So why is MS being forced on shit? It makes no sense. As for it being unfair to the User... why should I be forced to buy a computer with a bunch of crap on it that I don't need/want? IMO that's just another bunch of crap like all the other crap pre-packaged and installed when I buy a new computer. Trial subscriptions to Norton or McAfee, MS Office, couple of ISP programs like AOL and NetZero. Etc... Things that are there because people are trying to push products, advertise, etc... I'm only half-complaining here... I'm sure on some level I'm probably saving some tiny amount of money somewhere because of the money MS makes on the side from people bidding to have their shit packaged with Windows. Maybe. I hope. If not... well that's the point I'm trying to make...I didn't go out and buy a computer to have a bunch of people trying to advertise their shit to me. And seriously, some of that shit borderlines adware/straight up virus IMO. Some of that shit they make it real inconvenient to decline it being installed/used for the trial and real inconvenient to get it fucking uninstalled. And what do people hope to accomplish by forcing MS to package other browser options with Windows anyways? Browsers are easy as hell to install. You go to the website, click a button and it installs itself. People who know about other browsers already know how to get their favorite browser and have it up and running within minutes. People who are oblivious to such things...they are not going to know or care one way or the other regardless. They are just gonna see it as one more hoop to jump through when trying to get Windows running for the first time. One more choice to make that they don't know anything about and call their tech support buddy bothering them about. And I just wanna throw something silly out there...though it's not really a realistic scenario....it's not like an OS has to have networking capabilities. What if tomorrow MS decides that their OS will no longer support networking? Should they still be required to package other browsers with their OS? Overall I'm just trying to point out that this whole thing with MS being forced to package other people's browsers with their OS, offer install choices during initial Windows configuration, etc... is fucking bullshit. This is the "underdogs" sitting there thinking that average Joe user is too fucking stupid to be aware of other browsers out there, and they end up going with IE initially because that is what is initially on Windows, and they end up sticking with IE instead of going with other browsers because it does the job just fine and there's no reason to fix what ain't broke. So now these "underdogs" are trying to make out like it's somehow an evil thing that MS offers IE and not other browser choices. IMO this whole thing about forcing MS to offer alternate browsers to be pre-packaged on their OS is nothing but an underhanded attempt to get free advertising and exposure at MS's expense. I see people talking about how MS takes advantage of their size to push things and how they are so evil for doing it. But all I see on the other side of the fence is other people also taking advantage of MS's size and how "evil" they are to push their own shit. How is that any better? Especially when you know that the overall goal for them is to make money and make more of it, the same as MS. Pay attention. You will notice these "underdog" companies, their ideals, etc... are in direct proportion to their size and market %, and the higher % they get, the less their so-called principles shine as "noble". Never ceases to make me lol how people so readily root for the underdogs as if they are any better than the giant. Again, I am not some MS fanboy, I just try to look at it objectively. I am not saying MS is awesome, I'm simply saying at the end of the day, the "other people" aren't any better than them.
  20. Well, nobody is psychic. When you are literally sitting at 90% of the market share, there's no reason to believe that someone is going to knock you out of your throne. Fast-forward 10 years and you're down to 30%....sure, now you have a reason to start playing by everybody else's rules. And it's not like MS has just now started "getting with the program." As mentioned, they've been doing it in direct proportion to their market share, exactly as a business should. MS did not get to the top of the business food chain by making bad business decisions. And if nothing else, at the end of the day, we're all human. For most people, 20/20 vision is hindsight only. IMO, the best thing IE could have done was very early on, use their massive market presence to spearhead the movement - but according to their currently dominating standard. The fatal mistake MS made that made them go from 90% to currently around 30% was because instead of doing that - embracing the idea but on their own terms - they just lol'd at them and gave them the finger.
  21. Well see that was one of the things I was trying to address in my tl;dr... it took IE so long to start adhering to "the standard" because at the time, IE was the standard, and this whole "standard" started by w3c was just a couple of little companies trying to cut into MS's business. You wonder why IE has taken so long to "get with the program?" The answer in summary is: Because up until recently, they were the ones "running the show" - the majority % of the market - not the w3c. IE's presence has declined over the years, and Microsoft has "gotten with the program" in direct proportion of their market presence. I think maybe you and I are slightly crossing definitions of "standard". I am not talking about a "bar" set to a certain level in a "measurement of success." Though that certainly is one of the most prominent contributing factors of what constitutes a standard. I am talking about everybody being on the same page. Kind of like how functions and objects are meant to abstract details away, only on a browser level of context. For example...if 100 customers all need to buy ItemX, and there are 5 brands, and 90 of them buy brandX and the the other 10 people buy one of the other 4 brands, which brand would you say is the standard? Now let's say those 4 other companies (brands) decide to agree on certain things about ItemX, like how big it should be, how long it should last, what it should or should not do, etc... so that no matter how each of them went about making ItemX, it would still be familiar to people, can be used for the same purposes, etc.. regardless of brand. So now 100 more customers go and each buy a new ItemX. 90 of them still buy brandX, while 10 other customers buy one of the other 4 brands. So now we have 90 people who have ItemX doing the same thing, vs. 10 people who have ItemX that mostly does the same thing, but a bit differently. So while those 4 other brands are consistent amongst themselves, they now differ from that brandX, but overall, there's still 90 people using brandX and only 10 using the other brands. So tell me, which brand is "the standard" again? The underlying principle I am trying to convey here is that regardless of what you wanna call something, majority rules. In this case, majority is dictated by highest % of users using ItemX->BrandX. It is for this reason that 10% of the people/marketplace (more specifically, the collective minority of market presence), cannot rightfully claim they are the standard. So the point is, you can claim that there is this so-called w3c standard, and you can claim that browsers like Firefox are adhering to them and IE is not, but the numbers are all that matter. When IE is being used by 90% of users, the standard is IE, not w3c, and that's all there is to it. This idea of a standard is pure. The business of it is not. It makes no sense for MS to follow some so-called "standard" asserted by the minority of the market share.
  22. Personally I use jQuery for stuff like this, using .hover() and .slideUp() and .slideDown(). quick example code: <script type='text/javascript' src='jquery.js'></script> <div id='banner_main'> <img src='banner.jpg' /> <div id='banner_more_info'>extra info here</div> </div> <script type='text/javascript'> // initially hide the extra banner content...or initially hide it somewhere else or whatever $("#banner_main #banner_more_info").hide(); // when user hovers over banner... $("#banner_main").hover( // onmouseover, slide down info function() { $(this).find('#banner_more_info').slideDown(350); }, // onmousout, slideup function(){ $(this).find('#banner_more_info').slideUp(350); } ); </script> edited to clarify some of the code
  23. it changes certain characters like space, +, etc... and changes them to special values like space is %20. The reason for this is because those characters mean something special in different systems, so in order to ensure that the url gets read properly, those special characters are converted into something else, and then decoded later. For example, say you setup some function to accept a string and in that string there are values you parse and use a pipe as a delimiter: "foo|bar|blah" and then you would just split at the pipe delim and do whatever from there. But what if one of the values contains a pipe as part of the value? "foo|bar|bl|ah" The intention is to have 3 values: "foo" "bar" and "bl|ah" but your script doesn't know that, as far as it is concerned, you actually have 4 values. So in order to get around that, you have to make the script not recognize it as a delimiter. Sometimes it is simply escaped with a backslash, which is itself a form of encoding: "foo|bar|bl\|ah" Then the system will know that if the pipe is preceded by a backslash, treat it as a literal pipe and not a special character. But not every system follows this convention. Some systems use other codes to stand for the special symbols. The encodeURIComponent code for a pipe is %7C so it would make the string look like "foo|bar|bl%7Cah" and then you script would know that there are only 3 values and you would then decode the values and get and use your original "bl|ah" in a context where the pipe is not a special character. A more practical example in this context would be with a URL string... http://www.somesite.com/somepage.html?foo=bar&question=how are you?&answer=I am fine!&question2=what is 2 + 2?&answer2=2+2=4 Now imagine yourself trying to parse this example url. Task is to break it up into the various components. Protocol, host, domain, page, path, query string, query string values, etc... Can you notice from this example some red flags? For example, how do you know where the query string starts? Normally it is the ? but some of the values of the parameters also has a ? as part of the value so...how can you programatically know what is the query string delimiter and what is just part of a parameter value? Or with answer2=2+2=4 how do you know that the whole value is "2+2=4" and vs. trying to somehow parse that = sign as a different key=value? Or look how the forum rendered the url itself. Notice how the link broke at the first space? It failed to recognize the full string, because as far as it is concerned, in the context of this post, the url string stopped at the first space it encountered. Browsers are generally smarter about spaces in the url string if it's being put directly in the address bar or within href="...." tags because there are other overall delimiters it can look at. But not all browsers are smart like that... So yeah, overall, the point of url encoding is to make sure that urls don't end up breaking, because of certain characters that mean something special to the system(s) that process the url on different levels. Depending on the system(s) there are different conventions or ways of encoding the special characters, but overall the principle is the same.
  24. You know, it's real easy to just casually make vague statements like that...much harder to make an effort, put in the time and research to give reasons why. If you feel inspired to do so, I would like to remind you that there is a difference between "sub-par" and "alternate way of going about things," and I would like you to keep that in mind when trying to come up with a list of reasons why MS fails compared to everybody else. That is of course if you bother to actually put your money where your mouth is.... Lemme tell you a story. Microsoft had by far the most popular and widely used software in the world. For a long time. For the sake of story-telling, let's keep it simple and say they had about 90% of everything. Then there was the rest of the people who had like 10% collectively. Everybody had their own standards, not just Microsoft. So one day, those handful of people who made up that 10% decided that they should make a standard, because it's hard enough to make money when you all make up 10% of the market collectively, and making a standard increases odds of survivability. So they did that, and things were looking up. Then they decided that 10% just wasn't enough. Like virtually any business out there, the goal is to not sit there and idle at x revenue, but to increase revenue rate over time. So they thought "Hey, what if we make out like this is the world standard, and make out like MS is not being a team player by following this standard? This will surely shift the numbers over time." And it did, and it continues to do so. The moral of this story is that all these so-called "underdogs" are simply businesses who started out later in the game than Microsoft. While a lot of them may have differences in short term goals and philosophies, virtually all of them have the same long term goals and philosophies as Microsoft, which boils down to two things: making money, and increasing how much money they make over time. Everything else is Marketing strategy. Open source? Donating to starving kids in Africa? Saving little kittens? Marketing strategy, all of it. At the end of the day, FF, Chrome, Safari, etc...they are all businesses, just like Microsoft. They just aren't as big, so they make certain concessions and spin it off as being noble. A classic example is Net Zero. Remember how Net Zero claimed they would always be free and never ever charge for their shit because charging for internet access is no less than morally wrong, worthy of going to hell over? Funny how one day out of the blue they decided to charge for their services. Many people shook their heads in disbelief, felt betrayed, or just lol'd. But it was no more than anything else companies do, just a marketing strategy to get their foot in the door of market. Now, don't get me wrong, I believe there should be standards. I don't like having to do things like double and triple code javascript because of differing DOMs. Or hack the shit out of CSS to make it cross-browser compatible. Jobs are hard enough as it is, jumping through a million hoops to figure out what the client wants, getting shit approved, etc... throwing the need to have cross-browser compatibility into the mix on my level of things sucks, which is why I continue to hail things like jQuery as the greatest invention since sliced bread. But this unfounded and mis-informed hatred of Microsoft, as if they are the sole reason the interwebs is not some perfect Utopian architecture... I mean seriously, it's fucking annoying. Too many people way too eager to just jump on the "MS sucks monkey balls" bandwagon without doing some actual research and looking at the situation objectively. Many people spend all day happily and mindlessly bitching about how it is Microsoft not conforming to this self-proclaimed "world" standard, when the truth is, for the longest time, Microsoft was the standard, and up until a couple years ago, they were still the majority, and even to this day, they still hold a significant % of the market. You say "Why isn't MS conforming to the 'world standard'," but if you look at history objectively, you will find that it is MS that more had the right to say "Why aren't you conforming to us?" Now the obvious and immediate answer from your mouth will most certainly be "Because MS sucks." Well I invite you to reexamine your definition of suck, because the numbers say otherwise, and I have to say that that statement stems more from jealousy and envy than actual suckness. No, I am not some diehard Microsoft fanboy. I just believe in looking at stuff objectively: something most people tend to forget to do when they find something that works for them and steadfastly stick to it without dipping their feet in other waters, because after all, if it ain't broke, don't fix it, right?
  25. so do you hate IE because that's the "cool" thing to say or do you actually have a reason?
×
×
  • 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.