Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Remove blank space at the end of a variable?

Status
Not open for further replies.

bstonehill

IS-IT--Management
Feb 9, 2007
9
US
I am trying to extract the default gateway ip address using explode. I am able to successfully extract it but it contains a blank space at the end of the variable which prevents me from using the variable to load the webpage in javascript. Can anyone tell me how to automatically remove the last character from a variable?

$ipconfig = shell_exec('ipconfig /all');
$explode = explode(':', $ipconfig);
$gateway = explode(" ", $explode[14]);
$router = $gateway[1];

TIA
 
Code:
$router = trim($gateway[1]);
?

Greg
"Personally, I am always ready to learn, although I do not always like being taught." - Winston Churchill
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top