text formatting using eregi_replace

From: David (jaco2001uk_at_dontspamme.ntlworld.com)
Date: 11/28/03


Date: Fri, 28 Nov 2003 22:44:49 -0000

Hi,

I've had a search through google but couldn't really find the answer I was
looking for.I'm
new to PHP, so please take it <relatively> easy.

I've created a script which runs some SNMP queries. I'd like help if
possible in formatting one of the
values it returns.

When you run a query for the system uptime the result is displayed like so:

Timeticks: (4592345) 12:45:23.45

1.) I would like to remove the first two "fields" so I am left with:
12:45:23.45

I have managed to remove the Timeticks: part but don't know how to remove
the (4592345) (because this is of variable size).

$sysuptime = eregi_replace("Timeticks: ","",$sysuptime);

I don't know if it is possible but could you say remove everything within
the brackets - is that possible in a regular expression?
$sysuptime = eregi_replace("[()]","",$sysuptime); ???? (I tried that and it
didn't work ;) )

2.) If possible I would like to convert the output 12:45:23.45 to something
more like 12hr 45 mins

Obviously as the uptime increases that needs to incorporate _days_ as well.

3. Is it good/bad practice to use the same variable name twice in the
statement above?

Many thanks

David



Relevant Pages

  • Re: Websites 101
    ... > I am presently attempting my first commercial site and was hoping I ... Google Groups, and search the archive of this group, for example ... PHP is, uhm, a very bad designed programming language which has its ... Altough learning a programming language takes a lot of time, ...
    (alt.internet.search-engines)
  • Re: How is this possible?
    ... This is usenet and it has nothing to do with Google. ... Using php or any other server language to insert the query ... Just recreate the output with whatever code (in whatever language) ...
    (comp.lang.php)
  • Re: How is this possible?
    ... This is usenet and it has nothing to do with Google. ... Using php or any other server language to insert the query ... I'm just here to ask for simple advices on where to start. ... Just recreate the output with whatever code (in whatever language) you want. ...
    (comp.lang.php)
  • Re: [SLE] GUI webpage program needed
    ... If anyone points that sort of stuff at me it goes straight to ... > about 90% of the web sites) huge volumes of html are ... > database engines where google can't get at it. ... and the backend with PHP and MySQL on a Linux box. ...
    (SuSE)
  • Re: [PHP] Join question
    ... question doesn't belong even there because it has zilch to do with php, ... anything but bitch and complain. ... 1,930 results of which Google keeps track. ...
    (php.general)