-
Posts
14,780 -
Joined
-
Last visited
-
Days Won
43
Everything posted by .josh
-
Alternatives to Wikipedia you can use during the blackout
.josh replied to joe92's topic in Miscellaneous
I like how all the items in the list are images from wikipedia -
Didn't you guys invent the rotary washing line too? Where would we be without those, eh? That we did, but I think our contributions to medicine are probably the most significant. - Penicillin - Bionic Ear - Aspro - Spray on Skin - Zinc Cream - Ultrasound - Latex Gloves - Flu Vaccine - Night and Day contact lenses - Heart Pacemaker - Anthrax Vaccine to name a few, and we pioneered microsurgery. Some of other inventions/discoveries/innovations include... - Combine Harvester - The Sarich Engine - Wave Piercing Catamaran - Differential Gears - The 'Ute' (which is different to the 'pickup truck' developed in the USA) - Black Box Flight Recorder - Variable Ratio Rack and Pinion Steering - Hyshot Scramjet Engine - Electric Drill - Two Stroke Lawn Mower - Notepad - Telephane (yes Telephane, not Telephone) - Garage Roller Door - Salt Water Chlorination of Swimming Pools - Pre-paid Postage - Xerox Photocopying - Polymer Bank Notes - Blast Glass - Refrigeration - Vegemite (controversial topic as of late since the iSnack 2.0 incident) - Wine Cask - CETO Wave Energy System - Calyx Drill - Uniloc Software Protection (which after Microsoft copied, lost approx half a billion for stealing the technology) - Wireless LAN IEEE 802.11 - Samba Software - Google Maps (developed by a couple of Danish-Australian brothers in Sydney, believe it or not) - Feature Films (The Story of the Kelly Gang, 1906, ran for more than an hour) - The Australian Crawl - Race Cam - Speedo Swimwear - The Mills Cross - Gene Shears - SILEX - Synroc - The Stobie Pole I can't speak for the USA, but we improved it Well I'm rooting for you, oh wait, that means something else in Aus lol Yes lets keep quoting full posts instead of trimming them, I like it! I dunno...it seems like a good idea but it's also kinda annoying...
-
How about your niche be that you don't create tons of fake users?
-
http://www.phpfreaks.com/tutorial/basic-pagination
-
Deprecated: Function session_is_registered() is deprecated in
.josh replied to Function's topic in PHP Coding Help
look at your error. It is saying you already have a function called tep_session_unregister defined in another file. It tells you the other file and line. -
you can use cURL to get the image or a response.
-
converting the "&" symbol into special characters in URL
.josh replied to svgmx5's topic in PHP Coding Help
well he said he tried a urlencoded & and it didn't work. I suspect he's decoding it before parsing it. -
This topic has been moved to Third Party PHP Scripts. http://www.phpfreaks.com/forums/index.php?topic=351619.0
-
converting the "&" symbol into special characters in URL
.josh replied to svgmx5's topic in PHP Coding Help
would help if you show a full example URL and the code you're currently using. -
Other than unnecessarily escaping your forward slashes (they mean nothing special in regex, the only time you need to escape them is if you are using them as pattern delimiter, which you are not (you are using "~")), the regex works fine. example: $links = array( "http://www.example.com/news/somearticle1", "http://www.example.com/news/somearticle2/2", "http://www.example.com/news/somearticle3/3", "http://www.example.com/news/somearticle4/44", ); foreach ($links as &$link) { $link = preg_replace('~/?\d*/?$~', '', $link); } print_r($links); output: Array ( [0] => http://www.example.com/news/somearticle [1] => http://www.example.com/news/somearticle2 [2] => http://www.example.com/news/somearticle3 [3] => http://www.example.com/news/somearticle4 ) So your problem is somewhere else in your code. Maybe you are preg_replacing the wrong variable or assigning results to wrong variable (like a typo or something). Maybe later on you use the wrong variable to add new number on. Who knows, I'm just throwing out random guesses since you have no other code posted.
-
And what about the other ~185 (+/- a few depending on who you ask) independent countries? @TLG: LOL@pic
-
USA of course. We're holding aliens hostage in area 51, duh.
-
You asked for a push in the right direction and I explained what more you need to do. If you and your friend "cobbled" that together then you should have enough understanding to read what I wrote and apply it. Was there something in particular you didn't understand in my response? Do you need some clarification on a particular point in my reply? No offense, but I'm not sure what more I can do for you, short of writing the code for you...responding something vague like "I need help" when I gave you the help you asked for to me means what you're *really* asking for is for me to write your code for you, which I'm not going to do, because: 1) This smells like homework. What is the point in taking a class in something if you're just going to c/p and not actually learn anything 2) I'm not here to write your code for you. Unless you wanna pay me, then I will write it for you. This sort of conflicts with the first point but I'm not your dad; if you wanna waste your time in class not learning anything then that's on you.
-
non-regex on-liner alternative: $string = implode("/",array_slice(explode("/",$string,4),0,3));
-
This part needs to be modified: document.write(wordsArray[i]+ "<br />") // Output each word to the document and add a line break after each one if(wordsArray[i].indexOf("a") > -1) // Check to see if the word contains a letter a { aWordCount +=1; // If the word contains a letter a, add one to the count } You need to remove the linebreak tag from your document.write so that you can add the letter count next to the word. Or better yet, move your document.write below the code that determines how many instances of "a" are in it, so that you can document.write() everything in one go. Then inside your condition.. You need to either loop through each letter in wordsArray and increment a variable (example: numLetter) each time it matches the letter "a", or use a .match() regex instead of .indexOf() to match for it and count the returned results and put it into numLetter. Also note that you are currently doing a case-sensitive search, so for instance, it will not count the "A" in "Andy". Since you probably want it to be case-insensitive, you will need to first wordsArray.toLowercase() or use the i modifier if you opt for the regex approach. Finally, you will need to actually document.write numLetter after this code (and then add the linebreak tag) so that it will show the result next to the word.
-
Because I don't know how you are handling the keyword(s) to look for, and how you are looking to handle results, you may need to tweak this to suit your needs...but here is a function to get you started, based on the content you provided. /** * get_ids_by_keyword returns a list of thread IDs based off given keywords * @param string $content is the content to scrape * @param mixed $keyWords is a string (for a single keyword) or an array of * key words to search. * @param bool $pMatch is a flag to determine whether or not to match full * or partial words. Default is full match * @param bool $cs is a flag to determine whether or not search should * be case-sensitive. Default is case-insensitive * return mixed If results found, a multi-dim associative array is returned, * following this format: keyword => (id => instances). * NOTE: if $cs==false, keyword is returned lowercased. * If no keywords were matched, return false. */ function get_ids_by_keyword ($content, $keyWords, $pMatch = false, $cs = false) { if (!is_array($keyWords)) $keyWords = array($keyWords); $keyWords = implode('|', $keyWords); $results = array(); $b = ($pMatch == false) ? '\b' : ''; $c = ($cs == false) ? 'i' : ''; preg_match_all('~<span class="(?:comment)?postername">.*?<span id="no(?:thread|rep)(\d+)">.*?<blockquote>(.*?)</blockquote>~s',$content,$posts); foreach ($posts[2] as $i => $post) { if ( preg_match_all('~'.$b.'('.$keyWords.')'.$b.'~'.$c, $post, $keyWordFound) ) { foreach ($keyWordFound[1] as $kwf) { if ($c) $kwf = strtolower($kwf); $cid = $posts[1][$i]; $results[$kwf][$cid] = ( isset($results[$kwf][$cid]) ) ? ++$results[$kwf][$cid] : 1; } } } return ( count($results)>0 ) ? $results : false; } // end get_ids_by_keyword Basically you call the function passing the content to be scraped, and the keyword(s) you want to look for. It will then return a multi-dim associative array of the keyword(s) found, the post id of the post (including replies to posts) the keyword was found in, and how many instances of the keyword was found in the post. By default the function performs a case-insenstive full word search. There are optional arguments to make it case-sensitive and also return match for partial matches. Example 1: case in-sensitive full word search of 4 words within content of OP example. Notice how "boring" is not returned because the only instance similar within the content is "boringly" but this is flagged as a full word match. $keyWords = array('a','problem','boring','let'); print_r(get_ids_by_keyword($content, $keyWords)); Output Array ( [a] => Array ( [373301167] => 2 [373301334] => 1 ) [problem] => Array ( [373301167] => 1 [373301334] => 1 ) [let] => Array ( [373300183] => 1 ) ) Example 2: case in-sensitive partial word search of same 4 words. Now "boring" is matched because we flag it for partial matches. Also we get a lot of matches on "a" because it found a lot of them within words. $keyWords = array('a','problem','boring','let'); print_r(get_ids_by_keyword($content, $keyWords, true)); Output Array ( [a] => Array ( [373301167] => 9 [373301257] => 1 [373301298] => 3 [373301334] => 6 [373300183] => 2 [373301286] => 1 [373301297] => 1 ) [problem] => Array ( [373301167] => 1 [373301334] => 1 ) [let] => Array ( [373300183] => 1 ) [boring] => Array ( [373300183] => 1 ) ) Example 2: case sensitive partial word search. The first keyword is now capitalized. $keyWords = array('A','problem','boring','let'); print_r(get_ids_by_keyword($content, $keyWords, false, true)); Output: Array ( [problem] => Array ( [373301167] => 1 [373301334] => 1 ) )
-
@shamuraq a) the most immediate reason your preg_replace didn't work was because you have spaces between the part of your pattern that match for the numbers vs. the /, so it expects for instance "1 / 2" not "1/2". b) supposing your string does have a fraction with spaces in it like "1 / 2" your replacement basically just swaps out the "/" for a "|"...which..why? You said you wanted to mark it up with some html strong... @QuickOldCar: couple things about your regex.. a) since you are matching for a / it would be cleaner to pick a different pattern delimiter so you don't have to escape it in the pattern. b) [..] is a character class. It means to match any one thing inside the bracket. It is good for if you want to match for more than 1 thing like something in a range. For example [a-z0-9] will match any 1 letter or number. Since you are only matching for one thing (a "/"), while it *technically* works, there's no need for a character class. c) Your pattern will only match single-digit fractions. For instance, it will not match 1/10 (it will only match 1/1 part of it). @shamuraq: Here is a pattern for you: $pattern = '~([0-9]+\s?+/\s?[0-9]+)~'; This will capture the entire fraction $1 or \1 for your $replacement variable. This pattern will allow for both "1/2" and "1 / 2". If you only want it to match if no spaces, remove the two "\s?" parts.
-
Well php is a loosely (weak) typed language...
-
Installing WordPress isn't all *that* hard if you know what you're doing, and everything you listed I believe is already built-into it or has extensions for it, even multiple authors/blogs (WP used to have a separate multi-author/blog system at mu.wordpress.org but they have since combined it all into one system). It does take a bit more skill to customize it in the way of looks though..if you're looking to do a fully custom implementation. There are a ton of out-of-the-box skins/themes available for free or cheap if you're willing to settle for that though. But is it worth paying someone else $500 for? I know a lot of people who offer WP installs/customizations as part of their services (I know some people who ONLY offer that as a service) and they generally charge $300-$500 to do it, depending on how much customization you want. But I've also seen a lot of people charge a hell of a lot more...usually larger companies will charge more because they deal with larger clients. IMO it is worth the price if you don't want to take the time to learn it and do it yourself. Again, it's not terribly hard to do it if you know what you're doing, but it could quickly become really frustrating if other things prevent you from having a smooth install, like having to tweak/fix other server settings that are otherwise preventing it from going smoothly. But if you are interested in learning web dev stuff then it would probably be better for you to do it yourself; it's as good as any other place to get your feet wet. If you do opt to pay for someone to do it, I would find out if they are offer any kind of training to walk you through the interface, see where/how to do the stuff you want, etc... this may or may not be included in that price, and if you don't opt for that service, you may find yourself spending a fair chunk of time sorting that out, as well.
-
Well i guess point 1 you arent logged in yet so thats kinda superfluous. Point 2 you wouldnt be either but IMO you should show it on that page. And the others work under logged in status logic so really the only thing is first point.
-
Yes that makes sense...but isnt the common denominator between all those pages/scenarios that you ARE logged in? Therefore, you can just base the logic on logged in status.
-
have it show/hide based on logged in status. I assume you have a session var somewhere in there that is only set when user is logged in, yah?
-
@others: Whether or not it *should* be wiped is not really the point..if that's what doubledee wants to do, that's her prerogative. Though FYI I do agree, it is the de facto standard to not wipe it, even if it's incorrect. @doubledee: yes, that makes things clearer, but as others have said, can't really tell from the snippets of code what is going wrong, you should post complete version.
-
@doubledee: I was not being sarcastic. My point, which you missed, is that you aren't being very clear about your problem, it is not "spelled out", and I made a "best guess" accordingly, with a prefix of "If this is the case...".