Difference between revisions of "PHP-and-MySQL/C2/Arrays/English-timed"
From Script | Spoken-Tutorial
Sandhya.np14 (Talk | contribs) |
|||
Line 4: | Line 4: | ||
|- | |- | ||
|00:00 | |00:00 | ||
− | |Hello and welcome to the tutorial on Arrays. | + | |Hello and welcome to the tutorial on '''Arrays'''. |
|- | |- | ||
|00:03 | |00:03 | ||
− | |Arrays allow the user to store more than one piece of data inside a variable | + | |Arrays allow the user to store more than one piece of data inside a variable. |
|- | |- | ||
|00:08 | |00:08 | ||
− | |For example the variable days would be called as an array | + | |For example, the variable days would be called as an array. |
|- | |- | ||
|00:12 | |00:12 | ||
− | |Inside a pair of parenthesis we're going to have more than one value | + | |Inside a pair of parenthesis, we're going to have more than one value. |
|- | |- | ||
|00:17 | |00:17 | ||
Line 19: | Line 19: | ||
|- | |- | ||
|00:23 | |00:23 | ||
− | |I'll have Monday, Tuesday, Wednesday, Thursday and Friday - just 5 days of the week, that saves us | + | |I'll have Monday, Tuesday, Wednesday, Thursday and Friday - just 5 days of the week, that saves us. |
|- | |- | ||
|00:39 | |00:39 | ||
− | |Say for example day one is Monday, day two is Tuesday and so on. | + | |Say for example, day one is Monday, day two is Tuesday and so on. |
|- | |- | ||
|00:49 | |00:49 | ||
− | |Hope you get the picture | + | |Hope you get the picture. |
|- | |- | ||
|00:50 | |00:50 | ||
− | |This is a much easier and more efficient way of calling a variable with more than one piece of data inside it | + | |This is a much easier and more efficient way of calling a variable with more than one piece of data inside it. |
|- | |- | ||
|00:59 | |00:59 | ||
− | |Please note these can also be numbers | + | |Please note, these can also be numbers or whatever data that you decide you require inside them. |
|- | |- | ||
|01:07 | |01:07 | ||
− | |Now, to echo out our array, I'm going to say echo days | + | |Now, to '''echo''' out our array, I'm going to say '''echo''' '''days'''. |
|- | |- | ||
|01:12 | |01:12 | ||
Line 40: | Line 40: | ||
|- | |- | ||
|01:16 | |01:16 | ||
− | |This happens when we open up our page | + | |This happens when we open up our page. |
|- | |- | ||
|01:20 | |01:20 | ||
Line 49: | Line 49: | ||
|- | |- | ||
|01:24 | |01:24 | ||
− | |So, what PHP has done is echoed out the fact that what we have is an array. | + | |So, what '''PHP''' has done is echoed out the fact that what we have is an array. |
|- | |- | ||
|01:32 | |01:32 | ||
− | |Now, to call a specific element inside an array, you might want to call it element, in some places they call it id tags or elements of an array. | + | |Now, to call a specific '''element''' inside an array, you might want to call it element, in some places they call it '''id tags''' or elements of an array. |
|- | |- | ||
|01:41 | |01:41 | ||
Line 61: | Line 61: | ||
|- | |- | ||
|01:50 | |01:50 | ||
− | |However because of the numbering system | + | |However, because of the numbering system- the standard numbering system, we are starting with zero, one, two, three and four. |
|- | |- | ||
|01:58 | |01:58 | ||
− | |So | + | |So for example, if I wanted to '''echo''' out Monday that would be zero; so, you put zero in that and you have Monday echoed out. |
|- | |- | ||
|02:09 | |02:09 | ||
− | |The same with one would be Tuesday and four | + | |The same with one would be Tuesday and four which is the last element of the array, would be Friday. |
|- | |- | ||
|02:18 | |02:18 | ||
− | |Okay | + | |Okay. So, we're going to go ahead and I'm going to show you how to assign values in a different way into an array. |
|- | |- | ||
|02:26 | |02:26 | ||
Line 76: | Line 76: | ||
|- | |- | ||
|02:32 | |02:32 | ||
− | |I'm going to create an array | + | |I'm going to create an array but I'm going to create it specifically. |
|- | |- | ||
|02:39 | |02:39 | ||
− | |So, days zero equals Monday, days one equals Tuesday | + | |So, '''days''' zero equals Monday, '''days''' one equals Tuesday. |
|- | |- | ||
|02:53 | |02:53 | ||
Line 94: | Line 94: | ||
|- | |- | ||
|03:25 | |03:25 | ||
− | |So you can do it like that.I always prefer to do it like this. | + | |So, you can do it like that.I always prefer to do it like this. |
|- | |- | ||
|03:33 | |03:33 | ||
Line 100: | Line 100: | ||
|- | |- | ||
|03:45 | |03:45 | ||
− | |However if you prefer to view it, I mean if I save this now, refresh, nothing | + | |However, if you prefer to view it, I mean if I '''save''' this now, '''refresh''', nothing is changed. |
|- | |- | ||
|03:54 | |03:54 | ||
− | |There are no errors, we still get the same structure, we've just moved it down on lines | + | |There are no errors, we still get the same structure, we've just moved it down on lines. |
|- | |- | ||
|04:01 | |04:01 | ||
− | |There's the line terminator at the end of your function and not at the end of every line | + | |There's the line terminator at the end of your function and not at the end of every line; so, don't get confused with that. |
|- | |- | ||
|04:11 | |04:11 | ||
− | |Okay | + | |Okay. So, let's now go back to this. |
|- | |- | ||
|04:15 | |04:15 | ||
− | |So, that's the basic array and how to create values for it in two different ways and how to call values for it. | + | |So, that's the basic '''array''' and how to create values for it in two different ways and how to call values for it. |
|- | |- | ||
|04:23 | |04:23 | ||
− | |So, for example if I was saying echo Today is days and then I can say zero. | + | |So, for example if I was saying '''echo''' "Today is" days and then I can say zero. |
|- | |- | ||
|04:34 | |04:34 | ||
− | |Now, you can see already that I've highlighted this in context - I've highlighted that in green | + | |Now, you can see already that I've highlighted this in context - I've highlighted that in green. |
|- | |- | ||
|04:41 | |04:41 | ||
− | |Now, if you refresh this, you'll see this is Monday. | + | |Now, if you '''refresh''' this, you'll see this is "Monday". |
|- | |- | ||
|04:44 | |04:44 | ||
Line 130: | Line 130: | ||
|- | |- | ||
|04:53 | |04:53 | ||
− | |What it would look better is - you'll see that when we write it down here we could say echo 'days' and zero, you can see how that's in red to show an integer, a number. | + | |What it would look better is - you'll see that when we write it down here, we could say echo '''days''' and zero, you can see how that's in red to show an integer, a number. |
|- | |- | ||
|05:09 | |05:09 | ||
− | |The way it would like you to write is | + | |The way it would like you to write is like that and we can see, that's fine. |
|- | |- | ||
|05:16 | |05:16 | ||
− | |But you can incorporate an array into your string in order to echo it out. | + | |But you can incorporate an '''array''' into your string in order to '''echo''' it out. |
|- | |- | ||
|05:23 | |05:23 | ||
− | |Anyway, I'm going to go on to associative arrays where we're going to assign id tags in a way where we hold a value for each sort of identity. | + | |Anyway, I'm going to go on to '''associative arrays''' where we're going to assign '''id tags''' in a way where we hold a value for each sort of identity. |
|- | |- | ||
|05:36 | |05:36 | ||
− | |If you don't follow then this is the way I'm going to create it. | + | |If you don't follow, then this is the way I'm going to create it. |
|- | |- | ||
|05:46 | |05:46 | ||
− | |I'm going to say ages equals array, now inside, I'm going to say 'Alex' | + | |I'm going to say '''ages''' equals array, now inside, I'm going to say 'Alex'. |
|- | |- | ||
|06:03 | |06:03 | ||
− | |Now, instead of going on and saying Billy and then Kyle which are the three names I'm going to use, I'm going to say nineteen, fourteen and eighteen | + | |Now, instead of going on and saying Billy and then Kyle which are the three names I'm going to use, I'm going to say nineteen, fourteen and eighteen. |
|- | |- | ||
|06:20 | |06:20 | ||
Line 160: | Line 160: | ||
|- | |- | ||
|06:45 | |06:45 | ||
− | |So, really, it would be the same as writing that. | + | |So, really, it would be the same as writing that. Let's get rid of that and calling this as zero, one and two. |
|- | |- | ||
|06:55 | |06:55 | ||
− | |And to make it a bit more friendly | + | |And to make it a bit more friendly and a bit easier to remember, a bit easier to call, we can now say: '''echo''' out 'ages', 'Alex' like that. |
|- | |- | ||
|07:09 | |07:09 | ||
Line 169: | Line 169: | ||
|- | |- | ||
|07:24 | |07:24 | ||
− | |So, when you're half way through a program and instead of saying aah I'll have to go back to the top and count along each row and say "Is this zero, one, two or three I can't remember?" | + | |So, when you're half way through a program and instead of saying aah I'll have to go back to the top and count along each row and say "Is this zero, one, two or three, I can't remember?" |
|- | |- | ||
|07:38 | |07:38 | ||
Line 175: | Line 175: | ||
|- | |- | ||
|07:50 | |07:50 | ||
− | |We are not starting at zero and then one. We're starting at one and two | + | |We are not starting at zero and then one. We're starting at one and two so that we find that is easier to remember. |
|- | |- | ||
|08:00 | |08:00 | ||
− | |Now, we can now say echo | + | |Now, we can now say '''echo''' '''ages''' one, that comes out as 'Alex'. |
|- | |- | ||
|08:08 | |08:08 | ||
− | |We're not using zero for that, it's a lot more user friendly for you to program than to say | + | |We're not using zero for that, it's a lot more user friendly for you to program than to say- zero, one, two. |
|- | |- | ||
|08:17 | |08:17 | ||
Line 187: | Line 187: | ||
|- | |- | ||
|08:21 | |08:21 | ||
− | |But I mean this to me is quite pointless because I'm in the mood of using zero, one, two. | + | |But, I mean this to me is quite pointless because I'm in the mood of using zero, one, two. |
|- | |- | ||
|08:28 | |08:28 | ||
− | |But if you want to use it like I have before or like this or assign a string value to any data types then that's the way to do it | + | |But if you want to use it like I have before or like this or assign a string value to any data types then that's the way to do it. |
|- | |- | ||
|08:37 | |08:37 | ||
Line 199: | Line 199: | ||
|- | |- | ||
|08:47 | |08:47 | ||
− | |That's all in this tutorial. Thanks for watching. This is Arvind dubbing for the Spoken Tutorial project. Bye. | + | |That's all in this tutorial. Thanks for watching. This is Arvind, dubbing for the Spoken Tutorial project. Bye. |
Revision as of 12:32, 20 May 2015
Time | Narration |
00:00 | Hello and welcome to the tutorial on Arrays. |
00:03 | Arrays allow the user to store more than one piece of data inside a variable. |
00:08 | For example, the variable days would be called as an array. |
00:12 | Inside a pair of parenthesis, we're going to have more than one value. |
00:17 | So, I'll pick 5 values for this and have every day of the week inside each of these. |
00:23 | I'll have Monday, Tuesday, Wednesday, Thursday and Friday - just 5 days of the week, that saves us. |
00:39 | Say for example, day one is Monday, day two is Tuesday and so on. |
00:49 | Hope you get the picture. |
00:50 | This is a much easier and more efficient way of calling a variable with more than one piece of data inside it. |
00:59 | Please note, these can also be numbers or whatever data that you decide you require inside them. |
01:07 | Now, to echo out our array, I'm going to say echo days. |
01:12 | Now, you find that this doesn't work. |
01:16 | This happens when we open up our page. |
01:20 | We just get 'Array' echoed out. |
01:22 | Now, 'Array' is not anywhere inside here. |
01:24 | So, what PHP has done is echoed out the fact that what we have is an array. |
01:32 | Now, to call a specific element inside an array, you might want to call it element, in some places they call it id tags or elements of an array. |
01:41 | We're going to use square brackets and we'll call the position of the element inside the array. |
01:45 | So, you may think this is one, two, three, four, five. |
01:50 | However, because of the numbering system- the standard numbering system, we are starting with zero, one, two, three and four. |
01:58 | So for example, if I wanted to echo out Monday that would be zero; so, you put zero in that and you have Monday echoed out. |
02:09 | The same with one would be Tuesday and four which is the last element of the array, would be Friday. |
02:18 | Okay. So, we're going to go ahead and I'm going to show you how to assign values in a different way into an array. |
02:26 | Now, let me start from the beginning of what I want to say. |
02:32 | I'm going to create an array but I'm going to create it specifically. |
02:39 | So, days zero equals Monday, days one equals Tuesday. |
02:53 | Now, you may think - what's the point of this? I mean, what I'm doing here essentially is creating what I said earlier would be a bit of a hassle. |
03:04 | I mean I could say day 1 equals, you know and day 2 equals, and you could do it like that. |
03:15 | However, what we're still doing here is putting into an array. |
03:19 | So, it may still contain the same structure but we're assigning it in a different way. |
03:25 | So, you can do it like that.I always prefer to do it like this. |
03:33 | I find this much cleaner, much simpler and just to let you know - you can bring this down like this. |
03:45 | However, if you prefer to view it, I mean if I save this now, refresh, nothing is changed. |
03:54 | There are no errors, we still get the same structure, we've just moved it down on lines. |
04:01 | There's the line terminator at the end of your function and not at the end of every line; so, don't get confused with that. |
04:11 | Okay. So, let's now go back to this. |
04:15 | So, that's the basic array and how to create values for it in two different ways and how to call values for it. |
04:23 | So, for example if I was saying echo "Today is" days and then I can say zero. |
04:34 | Now, you can see already that I've highlighted this in context - I've highlighted that in green. |
04:41 | Now, if you refresh this, you'll see this is "Monday". |
04:44 | Now don't get confused, I do recommend you to use contexts. |
04:48 | However, this isn't the standard way that contact recognizes the coding. |
04:53 | What it would look better is - you'll see that when we write it down here, we could say echo days and zero, you can see how that's in red to show an integer, a number. |
05:09 | The way it would like you to write is like that and we can see, that's fine. |
05:16 | But you can incorporate an array into your string in order to echo it out. |
05:23 | Anyway, I'm going to go on to associative arrays where we're going to assign id tags in a way where we hold a value for each sort of identity. |
05:36 | If you don't follow, then this is the way I'm going to create it. |
05:46 | I'm going to say ages equals array, now inside, I'm going to say 'Alex'. |
06:03 | Now, instead of going on and saying Billy and then Kyle which are the three names I'm going to use, I'm going to say nineteen, fourteen and eighteen. |
06:20 | Basically using equals and a greater than sign. |
06:24 | Now, what this has done is instead of our array elements as in this being called by zero, this being called by one, this being called by two. |
06:34 | This is now called as 'Alex', this is called as 'Billy' and this is called as 'Kyle' but their values are fourteen, nineteen and eighteen. |
06:45 | So, really, it would be the same as writing that. Let's get rid of that and calling this as zero, one and two. |
06:55 | And to make it a bit more friendly and a bit easier to remember, a bit easier to call, we can now say: echo out 'ages', 'Alex' like that. |
07:09 | So, this will echo out nineteen, as we refresh and see there - nineteen. The same if you do it with 'Billy' and the same with 'Kyle'. |
07:24 | So, when you're half way through a program and instead of saying aah I'll have to go back to the top and count along each row and say "Is this zero, one, two or three, I can't remember?" |
07:38 | This is much easier to do. Another useful way of doing this is, if I was to say array one is equal to 'Alex' and then two is equal to 'Billy'. |
07:50 | We are not starting at zero and then one. We're starting at one and two so that we find that is easier to remember. |
08:00 | Now, we can now say echo ages one, that comes out as 'Alex'. |
08:08 | We're not using zero for that, it's a lot more user friendly for you to program than to say- zero, one, two. |
08:17 | Try it out - work around it - see what's easiest for you. |
08:21 | But, I mean this to me is quite pointless because I'm in the mood of using zero, one, two. |
08:28 | But if you want to use it like I have before or like this or assign a string value to any data types then that's the way to do it. |
08:37 | Okay, that's the basics of arrays, I have another tutorial on multidimensional arrays. |
08:44 | Its a separate tutorial. Please watch it. |
08:47 | That's all in this tutorial. Thanks for watching. This is Arvind, dubbing for the Spoken Tutorial project. Bye. |