note 38226 deleted from function.substr by tomsommer
| From: | tomsommer@php.net | Date: | Sun, 29 Feb 2004 01:59:34 +0000 |
| Subject: | note 38226 deleted from function.substr by tomsommer | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-65972@lists.php.net to get a copy of this message | ||
Note Submitter: d.hawk
----
A down and dirty function to grab an IP address. Works well on RedHat8.
function ipaddress ($interface) {
//function parses out the IP Address of the given $interface
$ip_string = trim(exec ("ifconfig $interface | grep inet"));
$ip_start = strpos($ip_string,"addr:")+5;
$ip_length = (strpos($ip_string,"Bcast:")-2) - $ip_start;
$ip_address = substr($ip_string,$ip_start,$ip_length);
return $ip_address;
}