Associate
- Joined
- 27 Apr 2004
- Posts
- 2,377
I'm trying to knock up a simple script for my website using PHP that will allow me to display information from my UPS on the status page. I've tried using apcupsd twice but no luck (since it has web based add ons already).
So instead I'm going to use Powerchute and try and use the log files from it.
Here is a sample of the first few lines:
I'm using file() to fetch the lines into an array and then using array_shift() to get rid of the column titles. However, I'm stuck on how to separate the values to make them individually accesable (probably into a multi-dimensional array, not sure yet). I tried explode() with a space as the separator but of course this only separated the date from the rest.
I need a way to explode at any number of spaces, not just one. So, I ask, how can I do this?
Thanks, null
So instead I'm going to use Powerchute and try and use the log files from it.
Here is a sample of the first few lines:
Date and Time Maximum Line Voltage Minimum Line Voltage Line Voltage Output Voltage Battery Voltage Output Frequency UPS Load UPS Internal Temperature Probe 1 Temperature Probe 1 Humidity Probe 2 Temperature Probe 2 Humidity
05/02/2006 19:37:12 N/A N/A 240.4 240.4 27.67 50.0 22.1 25.2 N/A N/A N/A N/A
05/02/2006 19:57:12 N/A N/A 240.4 240.4 27.67 50.0 22.1 25.6 N/A N/A N/A N/A
I'm using file() to fetch the lines into an array and then using array_shift() to get rid of the column titles. However, I'm stuck on how to separate the values to make them individually accesable (probably into a multi-dimensional array, not sure yet). I tried explode() with a space as the separator but of course this only separated the date from the rest.
I need a way to explode at any number of spaces, not just one. So, I ask, how can I do this?
Thanks, null