[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

reading file from a directory?

Posted on 2002-05-09
2
Medium Priority
?
151 Views
Last Modified: 2006-11-17
hai all,

I wanted to read a dir & choose a particular file.
I wrote as follows:
$dir=dir("/home/ftp/rf_auto");
    while($file=$dir->read()){
     if(substr($file,14,8)=="rf_auto2" && (substr ($file,-12,8)==substr($filename,-12,8))){
     $fcontents1=$file;
     exit();
     }

in this loop I wanted to exit the loop once I select the file($file).
How do I do this?

Thank u,
baska


0
Comment
Question by:baska
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 

Author Comment

by:baska
ID: 6998418
//there should be one more closing bracket.
}
//my requirement is,it should not read until end of the dir
//how to implement the condition.

thank u
baska
0
 
LVL 32

Accepted Solution

by:
Batalf earned 150 total points
ID: 6998593
You should use break; instead of exit;

Exit; is used to exit the script, break is used to break out of a loop:

$dir=dir("/home/ftp/rf_auto");
   while($file=$dir->read()){
    if(substr($file,14,8)=="rf_auto2" && (substr ($file,-12,8)==substr($filename,-12,8))){
    $fcontents1=$file;
    break;
    }
}
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

3 proven steps to speed up Magento powered sites. The article focus is on optimizing time to first byte (TTFB), full page caching and configuring server for optimal performance.
There are times when I have encountered the need to decompress a response from a PHP request. This is how it's done, but you must have control of the request and you can set the Accept-Encoding header.
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
Suggested Courses

649 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question