Jump to content

substr_count help


dk4210

Recommended Posts

Hello Guys,

 

I have a var that contains sub strings like this

 

test058.gif,test1058.gif,test698.jpg,

 

I want to be able to count how many times the images appear

 

How would I do that with substr_count?

 

I tried this

 

$subn = $_SESSION['fname'] . $_SESSION['lname'] ;
    foreach (glob("temp_photo/$subn*.*") as $filename3) {
   // echo "$filename<br>";


$string = $filename3;
$filename4 = basename($string);

$phstring2 .= $filename4 . ",";
    
echo $phstring2;

echo substr_count($phstring2, ',');
    }

 

But didn't work correctly..

 

Thanks for your expert help

 

Link to comment
Share on other sites

Abra,

 

I do have one more question if you have a second.. How do i check to see how many fines are in a directory without refreshing or submitting (POST)

 

Basically what I want to do is this

 

I have an upload feature on the page and I want to allow up to 8 images to upload and when the user uploads the 8th image I want the upload option to disappear..

 

 

This would do the trick if I was submitting the form.

 

$subn = $_SESSION['fname'] . $_SESSION['lname'] ;
    $files = glob("temp_photo/$subn*.*");
    $count = count($files);
    
    echo $count;

if (count <  {

echo "upload_html";

}


 

I think this will have to be done with ajax.. Any input?

 

Thanks, Dan

 

 

 

Link to comment
Share on other sites

hmm that's interesting.. The problem is that the upload form displays in the entire form. Short of submitting will checking the session upload count and cause the upload form to disappear when 8 images have been uploaded?

 

I don't understand.  To upload 8 files they will have to submit 8 times yes, or do you have it constructed some other way?

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.