file_handle = fopen("skunames.csv", "rb");//Opens file fclose($file_handle);//Closes file //This parses any csv directly into an array: $file = "skunames.csv"; $StrToArray = array_map('str_getcsv', file($file));//Needs the file unopened while (!feof($file_handle) ) { $ParseArrayFields = fgetcsv($file_handle);//Needs the open file $GetsStrFromLine = fgets($file_handle);//Needs the open file $SplitsStrgs = explode('=', $GetsStrFromLine);//Needs strings } //print $parts[0] . $parts[1]. "
"; // firstLine = array_shift($lines); // lines = explode("\n", $csv); // // // $file = fopen("skunames.csv","r"); // while (!feof($file) ) { // $line_of_text = fgets($file); // if (in_array("A0012", $line_of_text)){ // echo "found it"; // } //} //echo var_export($file); //fclose($file); // // // ///////////////////////////////////////////////////////////////// //This code works and breaks a csv file down into an array of 1 letter elements for each line// regex and file name are the only things that need to be modified $file = "skunames.csv"; $file_handle = fopen($file, "rb");//fopen Opens file while (!feof($file_handle)) {//while the file is open, until the end of the file...do something $GetsStrFromLine = fgets($file_handle);//fgets Needs the open file to return a string for each line in the file. $SplitsStrgs = explode('=', $GetsStrFromLine);//Explode Needs strings (not an array) to split foreach($SplitsStrgs as $line){ $string = $line; //var must contain a string $chars = preg_split('//', $string, -1, PREG_SPLIT_NO_EMPTY); //splits strings with regex var_dump($chars); } } ///////////////////////////////////////////////////////////////// Regex matches . = any character ^. = any character at the begining {5} = length of characters to look for \/ = match / \| = match | ^.{5}\/ = matches any of the first 5 charaters that end with / (^.{5}) = first 5 characters \d{1,5}\s\w+\. "a digit" \d "between" {1,5} "1 to 5 digits in length" \s "followed by a space" \w "with characters.." + "with one or more characters" \. "ending with a ." (?:[0-9])+ = Matches any numbers after the first letter....ie: A0012/B0012/D0032 matched: 0012 0012 and 0032 ///////////////////////////////////////////////////////////////// //Almost working (albeit unfinished) code below: (I'll just keep adding this to my graveyard of wasted scripts.... not frustrated...not at all... it's cool...I'll probably have to do this again next week too...) /////////////////////////////////////////////////////////////////