Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
配列フィルターを使用して、配列から特定の長さ以下の文字列を削除する方法を考え出そうとしています。
基本的にこれを配列フィルターで作り直したいのですが、
if( strlen($news_ps[$x]) < 5)) { remove this string from array }
$result = array_filter( $originalArray, function ($value) { return strlen($value) >= 5; } );
編集
インデックスも並べ替えたい場合は、 array_values() への呼び出しで全体をラップするだけです
$result = array_values( array_filter( $originalArray, function ($value) { return strlen($value) >= 5; } ) );