Beste leden,

Ik ben een VPS control panel zoals(Virtuozzo en Hypervm etc.) aan het maken. Het lukt al aardig maar ik ben bezig met explode enz. Ik heb heel veel overbodige spaties:
Array ( [0] => [1] => [2] => [3] => [4] => [5] => VPSID [6] => [7] => [8] => [9] => [10] => [11] => NPROC [12] => STATUS [13] => [14] => IP_ADDR [15] => [16] => [17] => [18] => [19] => [20] => [21] => [22] => [23] => HOSTNAME [24] => [25] => [26] => [27] => [28] => [29] => [30] => [31] => [32] => [33] => [34] => [35] => [36] => [37] => [38] => [39] => [40] => [41] => [42] => [43] => [44] => [45] => [46] => [47] => [48] => [49] => [50] => [51] => [52] => [53] => [54] => 101 [55] => [56] => [57] => [58] => [59] => [60] => [61] => [62] => [63] => 10 [64] => running [65] => 193.33.60.60 [66] => [67] => [68] => [69] => tmp [70] => [71] => [72] => [73] => [74] => [75] => [76] => [77] => [78] => [79] => [80] => [81] => [82] => [83] => [84] => [85] => [86] => [87] => [88] => [89] => [90] => [91] => [92] => [93] => [94] => [95] => [96] => [97] => [98] => [99] => [100] => [101] => [102] => [103] => [104] => [105] => 102 [106] => [107] => [108] => [109] => [110] => [111] => [112] => [113] => [114] => [115] => 3 [116] => running [117] => 193.33.60.61 [118] => [119] => [120] => [121] => vps05.dream-hosting.eu [122] => [123] => [124] => [125] => [126] => [127] => [128] => [129] => [130] => [131] =>
Hoe kan ik dat weghalen? Mijn script:
<?

$connection = ssh2_connect('localhost', 22);
ssh2_auth_password($connection, 'root', '');
$stream = ssh2_exec($connection, 'vzlist -a'); 
stream_set_blocking($stream, true); 
$cmd=fread($stream,8192); 



?>
<h2>VPS List:</h2>
<br>
<?
$list = explode(" ", $cmd);


print_r($list);



?>

B.V.D.,
A. Janssen

<?php

foreach($Array AS $Key => $Value) {

if(!empty($Value)) {
$Goed_Array[$Key] = $Value;
}

}

?>


Werkt zoiets niet..? Rechtstreeks kopieren gaat niet lukken bij dit kleine stukje code :p
Array ( [5] => VPSID [11] => NPROC [12] => STATUS [14] => IP_ADDR [23] => HOSTNAME [47] => [54] => 101 [63] => 10 [64] => running [65] => 193.33.60.60 [69] => tmp [98] => [105] => 102 [115] => 3 [116] => running [117] => 193.33.60.61 [121] => vps05.dream-hosting.eu [131] => )
krijg ik nu maar bij elke vps is het nummer heel anders en dit moet de vps list worden dus wat ik uit eindelijk wil is:
Array ( [1] => VPSID [2] => NPROC [3] => STATUS [4] => IP_ADDR [5] => HOSTNAME [6] => [7] => 101 [8] => 10 [9] => running [10] => 193.33.60.60 [11] => tmp [12] => [13] => 102 [14] => 3 [15] => running [16] => 193.33.60.61 [17] => vps05.dream-hosting.eu )
<?php

foreach($Array AS $Key => $Value) {

if(!empty($Value)) {
$Goed_Array[] = $Value;
}

}

?>

Af en toe is het leven zo simpel ;)

Reageren