Input data array using php function
this is my code
public function showInterfacesStatus()
{
$this->_send('show interfaces status');
$this->_readTo($this->_prompt);
$result = array();
$this->_data = explode("\r\n", $this->_data);
for ($i = 0; $i < 2; $i++) array_shift($this->_data);
array_pop($this->_data);
$pos = strpos($this->_data[0], "Status");
foreach ($this->_data as $entry) {
$temp = trim($entry);
if (strlen($temp) > 1 && $temp[2] != 'r' && $temp[0] != '-') {
$entry = array();
$entry['interface'] = substr($temp, 0, strpos($temp, ' '));
$entry['description'] = trim(substr($temp, strpos($temp, ' ') + 1,
$pos - strlen($entry['interface']) - 1));
$temp = substr($temp, $pos);
$temp = sscanf($temp, "%s %s %s %s %s %s");
$entry['status'] = $temp[0];
$entry['vlan'] = $temp[1];
$entry['duplex'] = $temp[2];
$entry['speed'] = $temp[3];
$entry['type'] = trim($temp[4] . ' ' . $temp[5]);
array_push($result, $entry);
} // if
} // foreach
$this->_data = $result;
return $this->_data;
}
How can I insert the data array into a table?
My table name: showInterfacesStatus and database name: Cisco
this is my code
public function showInterfacesStatus()
{
$this->_send('show interfaces status');
$this->_readTo($this->_prompt);
$result = array();
$this->_data = explode("\r\n", $this->_data);
for ($i = 0; $i < 2; $i++) array_shift($this->_data);
array_pop($this->_data);
$pos = strpos($this->_data[0], "Status");
foreach ($this->_data as $entry) {
$temp = trim($entry);
if (strlen($temp) > 1 && $temp[2] != 'r' && $temp[0] != '-') {
$entry = array();
$entry['interface'] = substr($temp, 0, strpos($temp, ' '));
$entry['description'] = trim(substr($temp, strpos($temp, ' ') + 1,
$pos - strlen($entry['interface']) - 1));
$temp = substr($temp, $pos);
$temp = sscanf($temp, "%s %s %s %s %s %s");
$entry['status'] = $temp[0];
$entry['vlan'] = $temp[1];
$entry['duplex'] = $temp[2];
$entry['speed'] = $temp[3];
$entry['type'] = trim($temp[4] . ' ' . $temp[5]);
array_push($result, $entry);
} // if
} // foreach
$this->_data = $result;
return $this->_data;
}
How can I insert the data array into a table?
My table name: showInterfacesStatus and database name: Cisco