1 00:00:00 --> 00:00:05 A multidimensional array is an array in which you can store other arrays. 2 00:00:06 --> 00:00:08 It is very similar to an associative array. 3 00:00:09 --> 00:00:13 However, the associates for this array are arrays themselves. 4 00:00:14 --> 00:00:18 For a better understanding, let us start the program. 5 00:00:19 --> 00:00:25 I will create a program that lets you see the position of a letter in the English alphabet. 6 00:00:26 --> 00:00:32 For example, if I give the value 1, it should echo out "A" in position 1. 7 00:00:33 --> 00:00:37 If I give the value two it would say "B" in position 2. 8 00:00:38 --> 00:00:42 And for three, it will say "C" is in position 3, and so on. 9 00:00:43 --> 00:00:52 First I will create my own array. 10 00:00:53 --> 00:00:57 And just for easy viewing, I will bring this down. 11 00:00:58 --> 00:01:00 You are quite welcome to do so yourself. 12 00:01:01 --> 00:01:09 And inside. I will create my own array, which I will call ‘ABC’. 13 00:01:10 --> 00:01:14 That will be the array. 14 00:01:15 --> 00:01:23 Instead of putting a value here, as we did before, we have an array inside. 15 00:01:24 --> 00:01:31 And inside these, will be the values, for example, Capital A, B, C and D. 16 00:01:32 --> 00:01:40 And these values will be separated by commas. 17 00:01:41 --> 00:01:45 And then we type “123” and that is equal to an array. 18 00:01:46 --> 00:01:52 Now we’re just going to have ‘1,2,3,4, and that’s it. 19 00:01:53 --> 00:01:58 Down here, I’ll show you how to echo out specific data inside the array. 20 00:01:59 --> 00:02:01 We’ll call our main array. 21 00:02:02 --> 00:02:04 And we’ll call this array as well. 22 00:02:05 --> 00:02:12 And then the position of what you want inside the array. So it is an array inside an array. 23 00:02:13 --> 00:02:18 So I will just type ‘echo’ and then ‘alpha’ which is our main array. 24 00:02:19 --> 00:02:22 And then inside square brackets, ‘ABC’. 25 00:02:23 --> 00:02:29 And next, inside square brackets, the position of the element if you want to retrieve. 26 00:02:30 --> 00:02:34 Now, for example, is going to echo "A". 27 00:02:35 --> 00:02:46 Let us give that a run - and we got "A". 28 00:02:47 --> 00:02:53 Changing this to ‘123’, will hopefully give us "1". 29 00:02:54 --> 00:02:56 As you can see here. 30 00:02:57 --> 00:03:04 So we've made our two basic arrays inside our main arrays, and we’ve learnt to call it. 31 00:03:05 --> 00:03:12 Now I’m going to create a new program to find out the position of a letter in relation to its number. 32 00:03:13 --> 00:03:29 I’m going to type up here ‘ postion = 0’, since 0 is the beginning. 33 00:03:30 --> 00:03:38 Now I will echo out ‘Letter something is in position something’. 34 00:03:39 --> 00:03:41 This is going to be quite simple. 35 00:03:42 --> 00:03:52 We enter a position here, say 3. Since C is in position 3 in the alphabet, we get C. 36 00:03:53 --> 00:04:01 So , to echo out our letter, if I am going to replace the first blank with ‘alpha’. 37 00:04:02 --> 00:04:04 ABC 38 00:04:05 --> 00:04:06 'pos' 39 00:04:07 --> 00:04:10 as 'pos' represents our position. 40 00:04:11 --> 00:04:18 So then, the position will be - Alpha... 123 41 00:04:19 --> 00:04:22 And then the position, ‘pos’. 42 00:04:23 --> 00:04:28 At the moment, position is equal to 0. 43 00:04:29 --> 00:04:35 We type ’echo something’. So this is position zero. 44 00:04:36 --> 00:04:46 Position zero inside the internal array “ABC”. So in actual fact, we are saying that A is in position 0, 45 00:04:47 --> 00:04:55 which is this array, 123 and that is position zero. So actually we are saying letter A is in position one. 46 00:04:56 --> 00:05:04 Lets run this. Okay. A is in position 1. Let’s change this to 1. 47 00:05:05 --> 00:05:20 Refresh. Letter B is in position 2. Now what I will do to make this application fully functional and easy to navigate, is eliminate the necessity to write zero for 1. 48 00:05:21 --> 00:05:27 So I will put ‘-1’ at the end and put 1 in brackets for better legibility. 49 00:05:28 --> 00:05:42 So, position one minus one is infact zero. So, writing 1 will give the same result as writing 0. Writing 2 will give us the same result as writing 1...letter B is in position 2. 50 00:05:43 --> 00:06:00 If I put 1 then we get A is in position 1. So if I put zero here; there is no position -1; so we get “letter in position”. So we don’t have the letter or the position. 51 00:06:01 --> 00:06:06 So, I’ve made that a bit more user-friendly. Thanks for watching!