Jump to content

.josh

Staff Alumni
  • Posts

    14,780
  • Joined

  • Last visited

  • Days Won

    43

Everything posted by .josh

  1. yes. You would style it just like how codeboxes are styled on web pages. Only you use the dropdowns and stuff. You can draw a box around it or insert a table. Make the background a certain color if you want. As Mchl pointed out, make the font different. Don't think there's any kind of automatic "syntax highlighting" built-in. Might have to make a script or post on a dummy board somewhere and I think if you c/p the results into ms word the colors should port over too (not 100% on that though...) If not, you'll have to manually do it..
  2. I wrote the code assuming you already had a multi-dim array, because that's what you said. So my code has to come after the while loop, after the multi-dim array is already generated. If you have it inside the while loop like that, You are just dealing with $array as a single-dim array, which is causing $row to not be a 2nd level array, but individual elements of data. Therefore you end up getting the array_diff error. If you want to have that stuff inside the while loop, then you need to get rid of the foreach loop and use $array instead of $row in the array_diff (and everywhere else that uses $row). Also, I'm just going to preemptively throw this out there...you originally said you already had your multi-dim array sorted a certain way before, and was then wanting to group the serial numbers. Well my code assumes that it IS sorted as you said. So if you are reading these lines from your file, if they are not already sorted in the file that way, it's not going to work the way you want it.
  3. yeah I'm not arguing that ^^ is probably more efficient on the processor...but I think this is one of those cases if I were coding it, I'd sacrifice that smidgen of efficiency for readability. edit: I mean, we are talking about a 6 row query...
  4. Think I'd rather stick with a regular while loop and array_reverse afterwards. Seems a lot more cleaner/clearer in intention if reading, imo.
  5. There's nothing being output in that php so it's impossible that that is the cause of your css problem. Look somewhere else.
  6. haha oops, you're right. my bad. ~@(\d+)~
  7. I smell spambot/scraper. Or dog shit. So hard to tell the difference.
  8. case (($row[wdir] >= 159) && ($row[wdir] <= 203)):
  9. that would just return "L" ....not to mention that it assumes that you even know the position of stuff in the array to begin with...
  10. If by greedy you mean preg_match returns first match vs. preg_match_all returns every match it finds, then sure, you can call that a greedy search. Though that might confuse people, considering that that term is used to describe quantifiers, and that is not the same kind of greedy... OP: Not really sure what you're overall goal here is, but if you're scraping pages, php will not be in the file unless it's somehow commented out, outside of php tags to begin with.
  11. You said if you enter "FREE" it works, but if you enter "FREE " it does not. In your code, trim it.
  12. What happened to the rest of your file reading part? What you have in that posted code only reads the first line. You need that while loop and that $i++ etc.. to create your multi-dim array when you are reading the file. And it doesn't look you changed $array to $data in the foreach argument. foreach($data as $row)
  13. Are you putting my code inside the while loop or after it?
  14. okay think about this monkey... The user goes to some random page that doesn't exist. So how exactly do you think that that script of yours is going to execute? The only way it will execute is if someone goes to that script, and therefore it's not a 404. In order to make a custom error page, you have to change a setting on the server itself. If you have cpanel access it should be really easy for you to find. Icon called "custom error messages/pages" or something. You should be able to have the server load a specific target page of your choosing when 404 is triggered (or any other server code for that matter).
  15. well are you using your real multi-dim array instead of $array in the foreach? Here is same code with example $array... <?php $array[] = array('serial'=>16,'color'=>'blue','width'=>'15mm','height'=>'25mm','weight'=>'50kg'); $array[] = array('serial'=>23,'color'=>'blue','width'=>'15mm','height'=>'25mm','weight'=>'50kg'); $array[] = array('serial'=>42,'color'=>'blue','width'=>'15mm','height'=>'25mm','weight'=>'50kg'); $array[] = array('serial'=>16,'color'=>'red','width'=>'15mm','height'=>'25mm','weight'=>'50kg'); $array[] = array('serial'=>16,'color'=>'red','width'=>'15mm','height'=>'25mm','weight'=>'50kg'); $prev = array(); $current = 0; // $array is your current multidim array foreach ($array as $row) { $diff = array_diff($row,$prev); unset($diff['serial']); if (count($diff) == 0) { $newList[$current]['serial'] .= ',' . $row['serial']; } else { $current++; $newList[$current] = $row; } $prev = $row; } echo "<pre>"; print_r($newList);
  16. $prev = array(); $current = 0; // $array is your current multidim array foreach ($array as $row) { $diff = array_diff($row,$prev); unset($diff['serial']); if (count($diff) == 0) { $newList[$current]['serial'] .= ',' . $row['serial']; } else { $current++; $newList[$current] = $row; } $prev = $row; } echo "<pre>"; print_r($newList);
  17. Serial # Color Width Height Weight 16 Blue 15mm 25mm 50kg 23 Blue 15mm 25mm 50kg 42 Blue 15mm 25mm 50kg so...which column decides whether something is in the same group or not? do all of columns have to match? Any of them? One or more?
  18. Meant no offense by it. Was saying, if you want to get a clear picture on how things work, spend some time meditating and visualizing and observing it.
  19. post the actual code you tried. I gave you an example of pattern -> replace directly with preg_replace. Looks like from your previous snippet you have an array that is being used.
  20. Read this tutorial. http://www.phpfreaks.com/tutorial/php-basic-database-handling teaches the basic concepts behind how to do basic database handling. Going from form to database and from database to presenting info, etc...
  21. Well the first piece of code you have doesn't connect to your database at all. Where is that happening? That's what you would want to change, instead of adding what you did (the 2nd piece of code you posted). If your code was working before with the 'localhost' wherever you were testing it, and now you have to point to somewhere else for this host you are using, all you should have to do is change 'localhost' to the database server specified by your host (according to your 2nd script, it looks like 'mydb.db.1234567.hostedresource.com').
  22. $string = preg_replace('~@\d+~',"<a href='#$1'>@$1</a>",$string); Although, if I remember correct, starting an id with a number is not allowed or else not conforming to the standards. You might want to prefix your anchor id's. Maybe something like this: <a name='post_xx'>... and then $string = preg_replace('~@\d+~',"<a href='#post_$1'>@$1</a>",$string);
  23. I haven't read the rest of the thread yet. Just got up to the in your OP. trim the posted input.
  24. My company just flew me to New York at the beginning of the month for some business. Place is too big and scary for me.
  25. Think about your example sites you listed though. Google, yahoo, hotmail, etc.. think of them as companies as a whole. Sure, they have captcha to weed out all the weaksauce bots because they are just so damn common, but think about what those companies mainly do: they are search engines, or have search engines/web indexers as a facet of their company. Don't you think it's in their best interest to know everything that's going on out there, what all is living out there on the web? Spend some time meditating on and visualizing the web, my friend.
×
×
  • 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.