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
https://forums.phpfreaks.com/topic/220266-substr_count-help/
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
https://forums.phpfreaks.com/topic/220266-substr_count-help/#findComment-1141495
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
https://forums.phpfreaks.com/topic/220266-substr_count-help/#findComment-1141520
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.