Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New Coder
    Join Date
    Nov 2004
    Posts
    78
    Thanks
    0
    Thanked 0 Times in 0 Posts

    how to get usefel data from string

    Hello

    I wish to get from

    $uptime = "05:54:13 up 1:54, 2 users, load average: 0.60, 0.47, 0.40";

    only the first value of load average , 0.60

    Anyone can help me ?

  • #2
    Regular Coder anarchy3200's Avatar
    Join Date
    Mar 2003
    Location
    England
    Posts
    261
    Thanks
    0
    Thanked 1 Time in 1 Post
    Untested but should do the job:

    PHP Code:
    $uptime "05:54:13 up 1:54, 2 users, load average: 0.60, 0.47, 0.40";
    $uptime_vars explode(','$uptime);
     
    print 
    $load_average substr(trim($uptime_vars), 144); 
    You may have to change the 14 in the substr if i miscounted but that shouldn't be far off.

    Hope this helps.
    Mike

  • #3
    New Coder
    Join Date
    Nov 2004
    Posts
    78
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thank you


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •