I get a whole list of arrays with different strings, and I want that the strings which contain "_pmx" be put in my dropdown list.
$buff = ftp_nlist($conn_id,"BackupFiles");
echo "<select id='pmxbestand' name='pmxbestand'>";
foreach($buff as $i=>$value) {
$resultaat = strstr($value, '_pmx');
echo "<option value='".$resultaat."'>".$resultaat."</option>";
}
echo "</select>";
I thought this would do the trick, but i开发者_如何学Ct turns out it doesn't, can anyone help me?
Try substr_count:
$buff = ftp_nlist($conn_id,"BackupFiles");
echo "<select id='pmxbestand' name='pmxbestand'>";
foreach($buff as $i=>$value) {
if (substr_count($value, '_pmx') > 0) echo "<option value='".$value."'>".$value."</option>";
}
echo "</select>";
I get a whole list of arrays with different strings, and I want that the strings which contain "_pmx" be put in my dropdown list.
How about:
foreach( $buff as $i => $value ) {
if( ( $result = strstr( $value, '_pmx' ) ) !== false ) {
printf( '<option value="%1$s">%1$s</option>', $result );
}
}
EDIT: Had a syntax error.
精彩评论