Learn, Share, Build

162
October 12, 2017, at 4:44 PM

Can somebody help me? I have many pictures with current name like : "black_abc","white_abc","black_cde","white_abc". How can I get only file with filename contains "abc"?

Answer 1

Can you use strpos()?

http://php.net/manual/en/function.strpos.php

<?php
 $arr = ["black_abc","white_abc","black_cde","white_abc"];
 foreach($arr as $i => $item) {
   if (strpos($item, '_abc')) {
     echo 'found _abc in ' . $item;
     echo '<br>';
   }
 }
?>

Output:

found _abc in black_abc
found _abc in white_abc
found _abc in white_abc
Answer 2

Use the glob() function like this :

<?php
$filename = "absolute path of the directory/*abc*";
foreach (glob($filename) as $filefound) {
    echo "$filefound size " . filesize($filefound) . "\n";
}
?>
Rent Charter Buses Company
READ ALSO
Learn, Share, Build

Learn, Share, Build

How convert it to php?

246
Learn, Share, Build

Learn, Share, Build

My form

204
Learn, Share, Build

Learn, Share, Build

In my database I have 2 tables:

212
Learn, Share, Build

Learn, Share, Build

I am trying to the the $json array in ascending order based on the value of the key idThe following is my code which has not worked so far?

222