Jump to content

ankme

New Members
  • Posts

    2
  • Joined

  • Last visited

    Never

Everything posted by ankme

  1. I have a function that searches first for a line in a file and then for a string in that line. If the string is not found, it concatenates the line with the next line and so on until it finds the string. The following script works but it is time consuming. I want to put a "break" somewhere so that if the line is found, the foreach will break. Can someone please help and tell me how to do this? If I put the break before the recursive call, it wont do the call. If I put it after, it wont get to the break. Thanks! function findEndTag($file, $line, $consolidatedLine) { $endTagFound = strstr($consolidatedLine,"/>"); if (!$endTagFound) { $fileContent = file($file); foreach ($fileContent as $i => $lineArray) { if ($lineArray == $line) { $consolidatedLine = $consolidatedLine." ".$fileContent[$i+1]; return (findEndTag($file, $fileContent[$i+1], $consolidatedLine)); } } } else { return $consolidatedLine; } }
  2. I have a file that contains, among others, some links to other files. Those files contain links to other files and so on. What I want to do is to check if a file has already been opened, and if this is true I want the file not to be opened again. For this I created an array, but when the code returns to the first file the array is reseted. Can someone please help me? This is the code I created (I`m a beginer in php). Thanks function readImportFiles($taxonomyFile, $target_path, $fileName='', $ArrayOfTaxonomies = array()) { while(!feof($taxonomyFile)) { $line = fgets($taxonomyFile); //code for getting the $schemaLocation if ($schemaLocation && !in_array($schemaLocation, $ArrayOfTaxonomies)) { $ArrayOfTaxonomies[]= $schemaLocation; $importSchema = fopen($schemaLocation, "r"); $target_path = substr($schemaLocation, 0, (strlen($schemaLocation) - strlen(strrchr($schemaLocation, "/")))); readImportFiles($importSchema, $target_path, $schemaLocation, $ArrayOfTaxonomies); } } }
×
×
  • 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.