Jump to content

Leaderboard


Popular Content

Showing content with the highest reputation since 01/23/2018 in all areas

  1. 2 points
    As you are sorting on "name", which is the first element of the sub-arrays, you can just use an ordinay sort() or rsort() call. (By default it will sort on the values oof the first element) EG $tadminlist["pvp"] = [ [ 'name' => 'mapname1', 'type' => 'pvp', 'beta' => 'y', 'final' => 'n', 'modded' => '', 'classification' => 'land', 'sf' => 'n', 'tod' => 'dawn', 'weather' => 'fog', 'es2' => 'y' ], [ 'name' => 'mapname3', 'type' => 'pvp', 'beta' => 'yy', 'final' => 'n', 'modded' => 'y', 'classification' => 'air', 'sf' => 'y', 'tod' => 'day', 'weather' => 'rain', 'es2' => 'n' ], [ 'name' => 'mapname2', 'type' => 'pvp', 'beta' => 'n', 'final' => 'y', 'modded' => 'n', 'classification' => 'sea', 'sf' => 'n', 'tod' => 'night', 'weather' => 'clear', 'es2' => 'n' ], ]; echo "line = " . join(', ', array_keys($tadminlist["pvp"][0])) . '<br><br>'; listData($tadminlist["pvp"]); echo "<br>SORTED ASC<br>"; sort($tadminlist["pvp"]); listData($tadminlist["pvp"]); echo "<br>SORTED DESC<br>"; rsort($tadminlist["pvp"]); listData($tadminlist["pvp"]); function listData($arr) { foreach ($arr as $tlist) echo join(', ', $tlist) . '<br>'; } OUTPUTS line = name, type, beta, final, modded, classification, sf, tod, weather, es2 mapname1, pvp, y, n, , land, n, dawn, fog, y mapname3, pvp, yy, n, y, air, y, day, rain, n mapname2, pvp, n, y, n, sea, n, night, clear, n SORTED ASC mapname1, pvp, y, n, , land, n, dawn, fog, y mapname2, pvp, n, y, n, sea, n, night, clear, n mapname3, pvp, yy, n, y, air, y, day, rain, n SORTED DESC mapname3, pvp, yy, n, y, air, y, day, rain, n mapname2, pvp, n, y, n, sea, n, night, clear, n mapname1, pvp, y, n, , land, n, dawn, fog, y To sort by any other element would require usort, eg to sort by classification usort($tadminlist["pvp"], function($a, $b) { return $a['classification'] <=> $b['classification']; } );
  2. 1 point
    @gizmola, You seem to be a drill-sergeant an loving father all in one?! I am very interested in learning how to do all of that, but I also stick to what I said (or implied) above... That being, I have a very large code-base I as working on a couple of years ago for a couple more years, and when I was 95% done, life happened and my work got tabled. My goal is to "finish what I started" and get my existing environment, tools, approach and code-base into prod so I can get my website up and try to make some $$$ while I regroup. (Starting to re-organize a Terabyte of crap on my old Macbook and laying it down in a way that I can actually find things on my new MacBook made total sense. But getting fancy with anything else is likely an unnecessary distraction...) And I am interested, but it was quicker to change a few lines of code in my httpd.conf file then do what you suggested. (For v2.0, I will check that and your other advice out.) There is nothing more than I want moving forward to learn how to code like a modern professional, and start being EFFICIENT, because that is what sunk me the first go around. (I have solid code that works, but it takes me 10 times longer to do and maintain things than it should for me to be successful. And, NO, that has nothing to do with tools, but has a s***load to do with architecture and coding styles!)) MAMP des what I need it to do for now. Took me an evening to research, and a few minutes to type the code to make it adapt to my new filing system. Now on trying to find all of my old code and notes and get my website working in my new dev environment on my new macBook. Thanks for the thoughts!
  3. 1 point
    It's case of "If you want to go there, I wouldn't start from here". If the second visit were a separate task (so the first two as task #1 and second two are task #2, then life would be easier. It's then simple (pseudocode) SELECT MAX(created) - MIN(created) GROUP BY task_id. You can then aggregate by each engineer for the day
  4. 1 point
    On reflection, I concur with Gizmola on the url and double quotes issue (There is a possibilty that a url could contain an apostrophe). In which case echo "<p><a href=\"$url\">Link here</a></p>"; It still avoids concatenation, which as you have demonstrated, can be error prone.
  5. 1 point
    Most things in a simplexml array are a simplexml objects. It is often necessary to cast elements as string types EG $title = (string)$row->title;
  6. 1 point
    Example pseudocode currentPost = 0 while fetch next record if postID != currentPost output post data set currentPost = postID endif output comment data endwhile
  7. 1 point
    I'm not following. You first state that you are using a regular expression to remove all but numbers from the values. Then you state that you want a value such as "Tnex>=40" to return Null or empty (as opposed to "40"). So, I'm not sure what you really want returned. Then you state that when you try to add the logic to your query you are not getting the rows that don't match the criteria. But, the query you provided doesn't have any where clause. If you had, I might have a better understanding of what you are really wanting from above. Lastly, the most important question is WHY are you doing this? If that data is not valid, then you should fix the data instead of creating complex process to handle the bad data on the output. I would update all the values in the database to just the number (or empty if you prefer) and implement logic when saving new values to ensure only valid data is entered. Although I would NOT advise the approach you are wanting, one of these will do what I think you are wanting Return the value if it is only a number - else return an empty string SELECT Date, Tnex, Mode, IF(Snex*1 = 0, "", Snex) as Snex FROM datatb Return the value with all non-numeric characters removed SELECT Date, Tnex, Mode, REGEXP_REPLACE(Snex, '[^0-9]+', '') as Snex FROM datatb
  8. 1 point
    It doesn't have to be at the beginning of the php code, it just has to be before any output is sent to the browser.
  9. 1 point
    You call it when you need the results (ie the list of files) $qt_folder_name = 'images'; foreach (get_files($qt_folder_name) as $imagename) { echo "<img src='$qt_folder_name/$imagename'><br>"; }
  10. 0 points
    I hope you two will be very happy together 😀
This leaderboard is set to New York/GMT-05:00
  • Newsletter

    Want to keep up to date with all our latest news and information?

    Sign Up
×

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.