Jump to content

Store a directory in an Array and call in code?


CaptSammy

Recommended Posts

I am trying to create a page that when run it does a "dir" on a windows share and finds a filename from the results that starts with ver and end with .txt (the actual page version is part of the filename). I have the parameters in a csv file, seemed easier than xml. Not having any luck, can someone shed some light and help me get this script running?

csv file:
'S01','Server1',"machine1","\\\\machine1\\iis$\\wwwroot\\"
'S02','Server2',"machine2","\\\\machine2\\iis$\\wwwroot\\"
'S03','Server3',"machine3","\\\\machine3\\iis$\\wwwroot\\"

php file:
<?php #Script - MyVerPage.php

// Create a multidimensional array from an external csv file

$CSVinput = fopen("MyCSV.csv", "r");
$MyArray = array();
$inputKEY=0;

while (list($shortID, $longID, $server, $rootshare) = fgetcsv($CSVinput, 1000, ",")) {
$MyArray[$inputKEY] = array(0 => $shortID, 1 => $longID, 2 => $server, 3 => $rootshare);
$inputKEY++;
}

$i=count($MyArray);

while ($i) {
  $chkcmd = $MyArray[$i][3];
  $d = dir($chkcmd);
  #find the filename from the dir list that starts with "ver" with extension ".txt" and assign to $result
  $MyArray[$i][4] = $result;
  echo $MyArray[$i][4];
  $i--
}

?>
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.