-
Posts
14,780 -
Joined
-
Last visited
-
Days Won
43
Everything posted by .josh
-
~^\S.*\S$~ however... what is your goal for this? Are you trying to kick back an error for invalid input or something? If the overall goal of this is to receive the data w/out the spaces on the ends, don't make the user re-enter it; just trim it. Not everything has to kick back an error. This is something unnecessary, like how when forms are programmed to kick back errors for improperly formatted phone numbers or dates. There's no reason to make the user go through the effort to enter in something exactly right, like dashes instead of parenthesis or slashes, etc..
-
[SOLVED] How to group numeric data that is in an array?
.josh replied to Mardoxx's topic in PHP Coding Help
$number_array = array(1, 6, 9, 6.1, 3, 2); $limit = 0.5; sort($number_array); foreach($number_array as $k => $n) { $diff = ($number_array[$k-1]) ? ($n - $number_array[$k-1]) : 0; if ($diff > $limit) $p++; $result[$p][] = $n; } -
As tendolla mention, I don't think it is the function causing the lag, but images being downloaded causing lag.
-
kwds: negative lookaround or you could just like, do if(!preg_match(....)) { ... }
-
yeah I read about this earlier today from a link on drudgereport.com The article I read basically said that yahoo agreed to sell the yahoo search engine/data to MS for whatever price, but MS has to provide yahoo with limited db read access to the info. Yahoo says they feel that letting MS run the search engine dept will free up time/money to focus on the other stuff they do.
-
bug with links underneath username
.josh replied to abazoskib's topic in PHPFreaks.com Website Feedback
Follow the link in the footer. -
bug with links underneath username
.josh replied to abazoskib's topic in PHPFreaks.com Website Feedback
...and you are reporting that here, instead of to the people who created SMF....why? -
what??? ! ??? ??? You've never heard of Tron? That's like a cult classic for computer geeks....go watch the original movie (just called "Tron" not "Tron Legacy")
-
what if he was your father?
-
[SOLVED] Grab the amount of [img] in a bbcode signature
.josh replied to killah's topic in Regex Help
sure, that will work. Except I'm not sure why you are subtracting 1 from the count...unless you have some sort of loop thing going on after that, I guess. -
[SOLVED] Grab the amount of [img] in a bbcode signature
.josh replied to killah's topic in Regex Help
$c = substr_count(strtolower($content),"[img]"); -
I wet my pants with happy juice watching that. Twice.
-
...and from there, there's no reason why you can't just do this: foreach($array as $k=>$v){ foreach($arrayEreg as $ereg){ if (ereg($ereg,$k)!==false) unset($array[$k]); } }
-
$color1 = $output_counts['#FFFFFF']; $color2 = $output_counts['#666666'];
-
You can have it echo the picture, force output to the browser, sleep, and force more output on the same page, but you cannot make it redirect after output, because headers have already been sent. If you are willing to have it on the same page instead of redirecting, you would use echo to echo out the picture, ob_flush to force it to output what's currently in the output buffer, sleep to time out for a bit, and then echo to display the rest of the content.
-
The link tells you what needs to go where. substr(string, start, length); string = the target string start = the starting position length = how long you want it to be $content = "really long text here"; $content = substr($content,0,100); not trying to be mean, but it's not exactly rocket science...
-
Can this function be modified to add a line break ?
.josh replied to David-fethiye's topic in PHP Coding Help
It's not entirely perfect, but it might be good enough for your needs... preg_match_all('~<[^>]+>~',$content,$tags); foreach($tags[0] as $tag) { $tagMasks[] = "<".++$x.">"; } $content = str_replace($tags[0],$tagMasks,$content); $content = wordwrap($content,70); $content = str_replace($tagMasks,$tags[0],$content); It doesn't completely ignore tags. It replaces them with <n> where n is a unique number. It then wordwraps with those <n>'s in there. It then replaces the <n>'s with original tags. This will prevent wordwrap from breaking up the tags, because there are no spaces in <n>. But since <n> is not zero width it will play a part in where the break occurs. Unfortunately, I can't really think of a way to completely ignore the tag and at the same time remember where they go. Could use regex to grab and remember stuff around each tag, but that cannot be guaranteed. I tested it out on some example content and IMO it works good enough, but that's justme. -
so...like I said, you are wanting to for instance take a 300 char count post and chop it off at say, 100 chars? Did you go to the substr link I provided? It sounds like that's what you want...
-
[SOLVED] generate unique number plus texts for each record
.josh replied to jkkenzie's topic in PHP Coding Help
having to go back and check to see if the currently generated one has not already been generated is very inefficient, especially with 10k records. md5 + microtime + loop = win. -
Not going to sift through all that code, but can you clarify: when you say "So I'm wondering, is there a code for it to reduce the characters to a specific amount?" Do you mean if the total character count in the content is for example 300 chars, you want to get the first 100 chars only? substr
-
you can't really do this with php. php parses the script and then sends the results to the client. There are ways to force content currently in the output buffer and you can of course have your php then "sleep" for a bit after that, but trying to redirect after that will give you a headers already sent error. The best you can do is send client-side instructions to do a timed redirect. You can do it by outputting a meta tag or a bit of js to change the location.href after x time.
-
Complicated Date/Job Frequency calculation problem.
.josh replied to moonman89's topic in PHP Coding Help
moonman: I'm kind of sort of getting a vague idea maybe you are trying to figure out a "next available date" sort of thing, based off of a start date, frequency and target date. So for instance, if you have the following info: start date frequency A 2009-06-01 30 B 2009-06-15 10 C 2009-07-09 2 target date 2009-07-28 You are wanting... Next available date: A 2009-07-31 B 2009-08-04 C 2009-07-31 is that correct? -
Complicated Date/Job Frequency calculation problem.
.josh replied to moonman89's topic in PHP Coding Help
OP = Original Post or Original Poster, depending on the context. -
Complicated Date/Job Frequency calculation problem.
.josh replied to moonman89's topic in PHP Coding Help
I understood your OP to mean you have a target date, and you have a list of all these other dates with a number "frequency" and you wanted to know which date(s)+frequency = target date. I'm not really sure what you're asking in this last post though. -
use two files. Open the file that is continually being written to. take remove line 0-x. do what you will with the data, put it in a new file when you go back to first file, the "last parsed point" will always be line 0. take from pile 1, add to pile 2.