banner banner banner banner banner banner banner banner




























Blog

HOME

JESUS STUFF

HEALTH & FITNESS

WEBSITE TECHNOLOGY

FAVORITE MOVIES

HOME MAINTENANCE

Recent Posts

BRUSHES OR ROLLERS

IN, BUT NOT OF...

TWEAKS

PAINT AND RAIN

GABE SNOW

NOAH SNOW

WHERE DID IT GO?

HAVANA, FLORIDA

TSUNAMIS

HE IS RISEN

Archives

Pictures

THE STORY

THE LIFT

THE VIEW

THE SEAWALL

THE PINE TREE

THE KAYAK TRIP

FILMMAKING

MORE MEMORIES

Genealogy

DELOACH

HUGHEY

Personal

ABOUT

CONTACT

Weather

NWS SOUTHEAST

US SEVERE WEATHER

WUNDERGROUND

Marine

LOCAL TIDE CHARTS

OCEAN TRAFFIC

Hurricanes

FORECASTING

SPAGHETTI MODELS


FILE MANAGEMENT

MARCH 30, 2021



Weight Tracking

I've kept my online weight tracking system privately published, but have really enjoyed all I'm learning about text file management with PHP and HTML. It's been very interesting, as usual, to see just how much code is already out there and available to be adapted and adopted to meet my needs.

w3schools.com and php.net are great for purposes of research, but I particularly like stackoverflow.com and the interactive nature of Q&A on that site. I've found solutions for a great many of my needs on that particular site, and I've even managed to find plug-and-play examples for some of the code I needed. Best of all, everything I try to build brings with it a great deal of new examples and sample code that can be reapplied in future projects.

In my private weight tracking system, when I input and store the data, PHP defaults to store the data with the most current entries at the bottom of the file. That's fine with me overall, but it doesn't provide a very good user experience (UX) in some cases.

For example, I don't want a user having to scroll down through a long list of data to get to the most current entries. I would rather have them on top of the list so they are seen up front and on top. To avoid that problem, I found the following:

$file = array_reverse($file);

Applying a simple array_reverse allows me to reverse the order of a stored text file. That combined with a simple echo command re-sorts and displays a file with the most current data at the top of the list. Just what I wanted!


Copyright © 2021 Hutch DeLoach






Search Archives