-
Posts
14,780 -
Joined
-
Last visited
-
Days Won
43
Everything posted by .josh
-
foreach ($array as $k => $v) { if ($k % 2 != 0) unset($array[$k]); }
-
if (!preg_match("~^[a-z. -]+$~i",$name)) {
-
a like button for good posts replies in phpfreaks?
.josh replied to $php_mysql$'s topic in PHPFreaks.com Website Feedback
oh but i did not che4ck this category and my thread was in misc and later it was shifted so how was i to know? You would know by actually reading the forum descriptions. -
a like button for good posts replies in phpfreaks?
.josh replied to $php_mysql$'s topic in PHPFreaks.com Website Feedback
love all the guys here even if some are rude, have learned alot in this great forum :-) We seem to have two different ideas of "rude" within this context. My definition of rude in this context is that you couldn't bother to do a search before making this thread. Especially since "like" type features is a pretty damn common feature these days...seems like it should be common sense that it's been brought up before. Lots of times. I read this thread and thought "oh great, yet another person who doesn't bother to search for something, and what's worse, it's something that common sense dictates is a pretty damn common topic/feature." And I responded accordingly. The moral of the story is that if you're going to be rude and not bother making any kind of effort in research before making a new thread, expect a negative response. -
facebook prevents spam? hmm I could swore they embraced it.
-
what is the difference between a Web Portal and website?
.josh replied to rlecastro07's topic in Miscellaneous
A web portal is a device that sucks you into the web. A website is where you wind up after getting sucked through the portal. Don't forget your towel! -
I'm not all-seeing, but I would not say "a lot" of people have questions like that. I personally only see questions like that show up maybe once a week and they usually start out as regex questions. IMO this does not warrant a separate sub-forum. TBH I don't think we really need a Math sub-forum either...if memory serves correctly, that board wasn't spawned from debate, but from the whims of an old admin (/me makes a mental note to bring up removing that sub-forum).
-
a like button for good posts replies in phpfreaks?
.josh replied to $php_mysql$'s topic in PHPFreaks.com Website Feedback
holy crap, what a brilliant idea!!! I can't believe nobody ever thought about this or suggested it before! -
btw you can technically use [..] as the delimiter like so: <?php $str="abcef"; $str2 = preg_replace("[[a-d]]","x", $str); echo '$str='.$str.' '.'$str2='.$str2; ?> ...but I wouldn't recommend it, since brackets have special meaning in regex (used for character class), so it makes for less readable code.
-
I think people do that sort of thing because they aren't interested in having to register on a site to ask a question, so they just enter in random shit to jump through that hoop, no intention of returning later...or if they do, just make another random account. And in general I'm fine with anonymous posting... problem is that it opens the door for spambots :/
-
I'm serious though...wtf kind of site has that many individual pages? I can't even begin to imagine a site that would have that many "pages" worth of content except for a frakkin' library...but even then, why would they be individual pages and not stored in db with a template? Surely the real answer here involves cutting down how many physical pages you have...
-
frameworks, code conventions, waste of bloody time?
.josh replied to egghead's topic in Miscellaneous
Coding with frameworks are always slow in the beginning. They really start to shine after you have something built up and then want to add more later, or when other people want to come in and figure out what's going on and add/change stuff. It is definitely an investment and a lot of people who do ad hoc / random small projects tend to skip using a framework either because of lack of time or lack of seeing the point (and it is indeed hard to argue a point to doing it for random ad hoc small projects) -
what...what kind of site has 17 million pages?!?
-
Well as a developer, the problem isn't just about having the latest browser/patch, but the addons actually working for it. And as a web developer, you aren't just working in a single browser (or browser version), so you don't get the option to pick the "always up-to-date" Chrome option and give everybody else the finger. I need to make sure stuff works in FF, even if Chrome is my browser of choice, you know? And therefore I heavily depend on a handful of Addons to work with it, as it makes my job 1000 times easier, arguably possible at all.
-
well, we haven't made any changes to the forum software, haven't done any software upgrade since v2 RC5 a couple months ago, nor have we added any mods in a couple months soo...if this is something "new" then you changed something on your end. Different browser/OS (version)? Also, screenshots help. Also...you should be reporting this on the SMF community board...even if it is a bug, we don't make the SMF software!
-
Can't Figure Out Why My Form Won't Add Record To Database
.josh replied to MjM8082's topic in PHP Coding Help
what errors are you getting? Do you even have error reporting turned on? One thing I immediately see is some missing quotes in your $sql = "..."; line... -
maybe need to rephrase or give more explanation or more context or somethin' because as-is, your regex works, in that you get "Capitalized Words" in "mygroup" Array ( [0] => text="ALL CAPITAL LETTERS - Capitalized Words" [1] => [mygroup] => Capitalized Words [2] => Capitalized Words )
-
If I had to take a guess, you're probably doing '/\n+/' with single quotes. \n is treated as a literal backslash and n inside single quotes. Use double quotes "/\n+/"
-
I think you are missing the point... unless there's other stuff you aren't mentioning, the lookahead/behind assertions are overkill, not necessary. Does the code I just posted work for you? $1 is the first captured group in the pattern. ${1} is the same thing, but the {..} specifically tells php to look at $1 because you want to use that "4" afterwards, so it's there to keep it from being confused and try to use $14 (the 14th captured group - which doesn't exist).
-
you don't need lookaheads or lookbehinds, it's overkill...unless you are still not explaining the full context of the problem. $string = "# 147 . qwe $"; $string = preg_replace('~#(.*?\..*?)\$~', '3${1}4', $string);
-
what is causing this regex to fail when parsing longer strings?
.josh replied to bitt3n's topic in Regex Help
well you said you were getting a server error, so my guess is that your server ran out of resources trying to run it. Anyways, instead of all those conditions to look at preg_last_error() ..why not just echo out preg_last_error() ? But that's neither here nor there. -
Of course it will be mercilessly abused, you really think CV made 12k+ posts??? Admins have DB-power, and they are not afraid to use it.. Hey now... I have not altered my post count at all, my count is legit...though now that I think about it, not all of the posts may actually be available, do to forum crashes/migrations over the years :/ Now...as to whether they are all high quality, helpful posts or not.... lol
-
what is causing this regex to fail when parsing longer strings?
.josh replied to bitt3n's topic in Regex Help
Well that's why I suggested renaming the array elements after the match. Example: $string = "abc123def"; preg_match_all('~([a-z]+)~',$string,$matches); $matches['letters'] = $matches[1]; unset($matches[1]); print_r($matches); I mean sure, you will have to initially "on paper" sort out the numerical index of your named groups, but it's really not that hard to do... first parenthesis == 1, 2nd == 2, skip the non-captured groups when counting, etc... then your code can go about using $matches['namedelementhere'] as it was before. The difference though is that you aren't wasting time and memory with naming the groups in the regex and doubling the matched array. -
$tableRows = '<tr id="systemhalfTableRow_A1"><td>Hello</td></tr> <tr id="systemhalfTableRow_B12"><td>Hello</td></tr> <tr id="systemhalfTableRow_A2"><td>Hello</td></tr>'; $tableRows = preg_replace('~<tr id="systemhalfTableRow_A[1-2]">.*?</tr>~','',$tableRows); However...this isn't really perfect... if you have nested tables within this, it's not going to match right. You should really be using DOM to parse html, instead of regex.