Good afternoon everyone! : D I am creating a page in php that informs me of my local ip, I am doing this through the command: shell_exec('ipconfig')
until then it is fine as it returns the ip of my correct machine, however it does not return only the ip , but also Address Ipv6 , Ipv4 , subnet mask, Gateway ... finally returns the whole class there as when typing the command ipconfig
in the PC Command Prompt.
Here's my dilemma! I want it to print on the screen just the Ip , but it is printing a list and in the middle of this list is my ip. So the bright mind here thought it could print only the ip if the list was an array, assigns the value returned by the command to an array variable and printed the variable and the obvious happened, it printed:
Array ( [0] => a turminha toda do resultado do comando ipconfig e blá blá blá )
My entire list is index 0. I wanted to know if there is a way to split the array, to print only the ip or if there is another way to print only the ip of this list.
Thank you, if anyone knows I am very grateful :)
There goes the code:
<!DOCTYPE html>
<html>
<head>
<title>teste</title>
<META HTTP-EQUIV="Refresh" CONTENT="60">
</head>
<body>
<?php
$str = array(shell_exec('ipconfig'));
print_r($str);
?>
</body>
</html>