1
00:00:00,220 --> 00:00:04,280
In our HTML directory,
we also have a list of territories.

2
00:00:04,280 --> 00:00:07,147
Let's include those as well
within their own group.

3
00:00:39,804 --> 00:00:43,915
If we want to work with the entire
file as a single string,

4
00:00:43,915 --> 00:00:47,700
we can use a function
called file_get_contents.

5
00:00:50,187 --> 00:00:52,416
And pass the path to the file.

6
00:01:07,446 --> 00:01:11,268
Now we have the entire contents
of the file as a string, and

7
00:01:11,268 --> 00:01:13,620
we can do with it as we please.

8
00:01:13,620 --> 00:01:17,845
Let's say we just want to convert the
entire string to lowercase before we use

9
00:01:17,845 --> 00:01:19,082
it in our drop-down.

10
00:01:26,116 --> 00:01:27,645
Let's view this in the browser.

11
00:01:31,439 --> 00:01:35,410
You can see that the territories
listed are lowercase.

12
00:01:35,410 --> 00:01:37,020
Let's try one more function.

13
00:01:42,508 --> 00:01:47,830
We can also pull in the entire file
as an array of individual lines.

14
00:01:47,830 --> 00:01:50,521
Let's add the Armed Forces
locations as well.

15
00:02:12,602 --> 00:02:18,593
Our $state_array = file,
and we'll pass it the file.

16
00:02:27,890 --> 00:02:31,985
Now we can loop through each of these
lines just like we would any other array.

17
00:02:31,985 --> 00:02:36,585
Let's say that we want to remove
the Armed Forces text from each item

18
00:02:36,585 --> 00:02:40,391
since we already have a heading
that says Armed Forces.

19
00:02:47,434 --> 00:02:50,748
Foreach ($state_array as $line) {

20
00:02:58,606 --> 00:03:00,378
We'll str_replace again.

21
00:03:08,790 --> 00:03:12,804
And we'll replace Armed
forces with an empty string.

22
00:03:15,119 --> 00:03:17,766
Let's view this file in
the browser once more.

23
00:03:20,997 --> 00:03:25,931
Now we have the Armed Forces added to
our drop-down as well without the text

24
00:03:25,931 --> 00:03:28,530
Armed Forces before each of the items.

25
00:03:29,590 --> 00:03:33,360
These are the three basic ways we can
interact with a file on our system.

26
00:03:34,390 --> 00:03:39,642
Open a connection to the file, and
handle it line-by-line before closing it.

27
00:03:39,642 --> 00:03:42,729
Work with the entire file as a string.

28
00:03:42,729 --> 00:03:46,120
Work with the entire file as an object or
an array.

29
00:03:47,340 --> 00:03:51,410
We'll be expanding upon these objects and
arrays in the next section.

30
00:03:51,410 --> 00:03:54,360
But before that,
let's take a look at writing files.

