No video

20: How to Create a Foreach Loop in PHP | PHP Tutorial | Learn PHP Programming | PHP for Beginners

  Рет қаралды 128,795

Dani Krossing

Dani Krossing

Күн бұрын

How to Create a Foreach Loop in PHP | PHP Tutorial | Learn PHP Programming | PHP for Beginners. In this PHP tutorial you will learn about foreach loops which are often used in PHP scripts. Loops are used to loop through multiple pieces of data from arrays one at a time. Loops can help with spitting out a lot of data using little code.
➤ GET ACCESS TO MY LESSON MATERIAL HERE!
First of all, thank you for all the support you have given me!
I am really glad to have such an awesome community on my channel. It motivates me to continue creating and uploading content! So thank you!
I am now using Patreon to share improved and updated lesson material, and for a small fee you can access all the material. I have worked hard, and done my best to help you understand what I teach.
I hope you will find it helpful :)
Material for this lesson: / lesson-material-42361704

Пікірлер: 54
@jamesbarratt593
@jamesbarratt593 6 жыл бұрын
There are teachers out there that have no place being teachers, and then there’s guys like you Daniel who are like the GSP of UFC at teaching. Truly great watching your videos. once I have done your complete course from your website, I will donate. ps: I came from php manual and their explanation of foreach was just so confusing.
@senju31
@senju31 5 жыл бұрын
I generally don't like using the PHP Manual/Official website because I also find it confusing.
@omarbailal5751
@omarbailal5751 4 жыл бұрын
after 2 years what is your position now?
@maxmclaren8257
@maxmclaren8257 3 жыл бұрын
Exactly, I'm paying 2 grand per uni class and I'm having to result to Daniel's free content so that I can actually learn the stuff.
@gagandhillon4797
@gagandhillon4797 5 жыл бұрын
had spent time banging my head watching tutorials here. My search ended with your professional, considerate as well as warm videos. Thanks so much for these. Please keep up the good work.
@eldricost4384
@eldricost4384 3 жыл бұрын
I am 16 years old, and i love coding To thank this guy, i don't skip his ads and let it play until its gone
@SamyHadera
@SamyHadera 8 ай бұрын
Dude you are amazing exaplained everything better than my teachers
@Dani_Krossing
@Dani_Krossing 8 ай бұрын
Thanks 🙂 I have a newer PHP course on my channel btw. This one is old
@wudi8612
@wudi8612 7 жыл бұрын
Thank you for your tutorial. As a new learner of PHP and English, I find it's very useful, so I guess that means native speaker can easily understand.
@birdman8286
@birdman8286 7 жыл бұрын
Thank you mmtuts! I agree with others that your tutorials are among the best that I've found on KZfaq! Great job! :D
@Dani_Krossing
@Dani_Krossing 7 жыл бұрын
Thank you :) I'm glad you like them
@waldoglas3412
@waldoglas3412 Жыл бұрын
Thanks really helped me understand better than my lecturer. Easy understandable and enlightened. would recommend.
@axayPzea-qm8sv
@axayPzea-qm8sv 11 күн бұрын
A good explanation. in while loop, we echo values separately. we can add div's in both sides of output results so we can style. how to style foreach output values using Css?.
@skimerroyaltyfreefootages653
@skimerroyaltyfreefootages653 5 жыл бұрын
Thank you man for these excellent tutorials! PHP is so similar with JS and it's so easy when you know JS already. You are so great at explaining things!
@auras97
@auras97 5 жыл бұрын
Actually you can also do something like this foreach($array as $key=>$value) to acces both value and key. And i would suggest to add the way keys are assigned to new values added the the array.
@nancyfazal2536
@nancyfazal2536 6 жыл бұрын
You are truly a best Teacher. Very easy and effective tutorials. Thank You! stay blessed
@taishienglish
@taishienglish Жыл бұрын
You actual this concept very easy to understand. Thanks man, you def have a sub from me.
@Dani_Krossing
@Dani_Krossing Жыл бұрын
Thank you! 🙂 FYI, I have a brand new ongoing PHP course available on my channel. 🙂 In case you want to follow the "better" course I have. ☺
@yousifnyala4284
@yousifnyala4284 5 жыл бұрын
Super explanation you did such a great job bro cheer up keep up
@jahir_valverde
@jahir_valverde 3 жыл бұрын
Thanks
@princeiscpv
@princeiscpv 4 жыл бұрын
Thank you sir for your nice explanation.
@movine2344
@movine2344 6 жыл бұрын
After 10 times watch this video finally i understand TQ donuld trump
@daudsulaimon5795
@daudsulaimon5795 2 жыл бұрын
thanks man
@llBestBoyll
@llBestBoyll 2 жыл бұрын
nice video dani 👏🏼
@MdMorshedAlamBadhan
@MdMorshedAlamBadhan 7 жыл бұрын
Hi, Thank you for the tutorial.. but I have a question ! The variable "$loopdata" there is no value of it, but its working, how? could you please explain?
@Dani_Krossing
@Dani_Krossing 7 жыл бұрын
The loop data is only a placeholder to show where we want to spit out the data from the $array.
@wudi8612
@wudi8612 7 жыл бұрын
my browser showed me "undefined variable" for some reason, I checked my code its totally same.
@abzalomkyeuwkyeuw
@abzalomkyeuwkyeuw 5 жыл бұрын
The variable $loopdata have the value from variable $array.
@chriszuidema
@chriszuidema 5 жыл бұрын
Thank you!!
@unkownsiner
@unkownsiner 6 жыл бұрын
Bro what keyboard do you use? I don't know why but I find the clicking sound soo satisfiying lol
@fakhrinorhisham9372
@fakhrinorhisham9372 5 жыл бұрын
Why do we need to create a new variable in the foreach loop, for example in this video a variable called '$loopdata", why not use the '$array' itself? thanks =)
@cagedtigersteve
@cagedtigersteve 6 жыл бұрын
Just criticism of videos....most programmers understand the concepts of arrays and for each etc. It's the syntax of the unknown language that trips up most programmers. Like PHP using the dot for concatenation.
@yeshudavid7216
@yeshudavid7216 6 жыл бұрын
Sir, but why can't we directly use the variable name ($array) instead of referring it to another variable $(loopdata)? I did try this example, but I'm not getting why we need to assing the old variable to a new variable?
@reallyabe
@reallyabe 6 жыл бұрын
it is a placeholder for the values in the array. $array represents the entire array while $loopdata refers to each value. So echoing out $array would print out [name1, name2 etc.]
@RoshanShresthaOff
@RoshanShresthaOff 4 жыл бұрын
How to use foreach loop for multidimensional array ??
@romanticscents
@romanticscents 7 жыл бұрын
Very easy to understand! New Subbie here ♥
@reallyabe
@reallyabe 6 жыл бұрын
is this similar to for.. in in Python?
@shakils1921
@shakils1921 4 жыл бұрын
Which font is this?
@MonteLogic
@MonteLogic 5 жыл бұрын
Foreach loops are for $arrays
@movine2344
@movine2344 6 жыл бұрын
loop loop goood
@asasasdada8945
@asasasdada8945 7 жыл бұрын
Hello i had the same code as you and i got ( ! ) Parse error: syntax error, unexpected '(' in C:\wamp64\www\index.php on line 12 when my line 12 is perfect can u explain why?
@encryptionxyz4278
@encryptionxyz4278 7 жыл бұрын
let me see ur whole code, and probably didnt put a semi-colon in line 11
@TechnicalDhruva
@TechnicalDhruva 4 жыл бұрын
It might be due to this video is 1 year old and new php 7.1 is there
@whynottoday833
@whynottoday833 6 жыл бұрын
my foreach loop is not working. it is showing this in the browser "; } ?> please help.
@Dani_Krossing
@Dani_Krossing 6 жыл бұрын
If you see code like this, then it usually always mean that you made a typo in your code.
@whynottoday833
@whynottoday833 6 жыл бұрын
mmtuts ohk, I will surely check it. Thank you for your reply.
@movine2344
@movine2344 6 жыл бұрын
OMG i need help while loop,for loop,do while loop i able to loop but this loop my brain get loop pls i dont understand some one help me
@navjeetbharti544
@navjeetbharti544 4 жыл бұрын
@LordBenjamin1998
@LordBenjamin1998 4 жыл бұрын
The bad thing about your tutorials is that you use terms as a name for a structure: for example why give the array the name $array when you could choose "$names" or "$ar" since the part "array()" is repeated after the =. After that you give the name "$loopdata" when you could easily name it "$element" ose "$arrayelement". Apart from that everything is explained well, but you create confusions to someone who is new to PHP.
@peteb8104
@peteb8104 3 жыл бұрын
My thought exactly!
@mshahmirkhan
@mshahmirkhan 3 жыл бұрын
he looks like Elon Mask LOL
@zahidurrahman971
@zahidurrahman971 4 жыл бұрын
This is not the right way to teach beginners. This example is every where on the internet. You should teach its usage in real time data fetching. I am not happy with this
@Dani_Krossing
@Dani_Krossing 4 жыл бұрын
That’s okay :) I can’t satisfy everyone
@zahidurrahman971
@zahidurrahman971 4 жыл бұрын
@@Dani_Krossing I have watched this video about a year ago. I was not clear. When I search every time this video appears. It's actually youtube fault for ranking such old content.
❌Разве такое возможно? #story
01:00
Кэри Найс
Рет қаралды 4,1 МЛН
Люблю детей 💕💕💕🥰 #aminkavitaminka #aminokka #miminka #дети
00:24
Аминка Витаминка
Рет қаралды 724 М.
Kids' Guide to Fire Safety: Essential Lessons #shorts
00:34
Fabiosa Animated
Рет қаралды 17 МЛН
Blue Food VS Red Food Emoji Mukbang
00:33
MOOMOO STUDIO [무무 스튜디오]
Рет қаралды 24 МЛН
Foreach loops in PHP - Easily Iterate Over Arrays
9:37
Ken Swartwout
Рет қаралды 1,4 М.
PHP - foreach Loops and Associative Arrays
6:13
Steve Griffith - Prof3ssorSt3v3
Рет қаралды 18 М.
PHP Foreach Loop Tutorial
6:16
Clever Techie
Рет қаралды 104 М.
Learn PHP Language In 10 Minutes!! PHP Language Tutorial
10:23
Working With PHP Arrays the Right Way
16:10
Envato Tuts+
Рет қаралды 5 М.
PHP foreach loop explained with arrays, objects and key value
7:11
❌Разве такое возможно? #story
01:00
Кэри Найс
Рет қаралды 4,1 МЛН