Skip to content
Advertisement

how to assign a file to an array of elements which are part of the file

I have a directory which contains .txt files. In each .txt files are lines, under each other. the 2nd line is the category line. A txt file looks like this:

JavaScript

A couple of categorynames should be excluded form the other categories, like Offside and 2019 I have filtered the array like below:

JavaScript

What i need is an array of blogfiles in which the categories have been filtered in. I do not know how i can bind the corresponding blogfiles to the filtered array

Advertisement

Answer

Use in_array() to test each category, rather than using array_diff() on the whole array.

JavaScript
User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement