PHP - TRICKS WITH FOR LOOPS

Поделиться
HTML-код
  • Опубликовано: 14 дек 2024

Комментарии • 51

  • @mystique9
    @mystique9 4 года назад +2

    You're a wonderful teacher. I really liked the way you go step by step. I'm looking forward to seeing more of your educational videos. Thank you!

  • @Chandrajith100
    @Chandrajith100 4 года назад +1

    This is very pleasant and specific to the point video I saw. Thank you very much!!!

  • @samkthampan
    @samkthampan 4 года назад +1

    I think adding x+1 at name attribute is much better than adding a empty space for the prgm related to month......

  • @JP-lr8rr
    @JP-lr8rr 6 лет назад +18

    Instead of putting an empty element into the array, just start like this:
    $months = [ 1 => "January", "February", "March" ... ]
    It starts the element key at One instead of Zero and increments it by 1 for every upcoming element.

    • @walnut2983
      @walnut2983 6 лет назад +4

      oj just add 1 to $x

    • @StefanNovovic
      @StefanNovovic 4 года назад +2

      Use foreach($array as $k=>$v), you get keys indexed from 0 to whatever and your values ofc.

  • @DineshKumar-fl6db
    @DineshKumar-fl6db 5 лет назад +1

    Amazing explanation sir thank you so much share this vedio

  • @vNYCblade
    @vNYCblade 6 лет назад +4

    I know this video was related to ForLoops specifically, BUT, since once of the examples was how to generate sequential lists, specifically one with months of the year, i though it would be helpful to show a different way of doing it which is more advanced, BUT simpler and a lot more dynamic...
    $months = range(1,12); // This simple function generates an indexed array with values starting with 1 and ending with 12...
    This is the output of $months...
    Array
    (
    [0] => 1
    [1] => 2
    [2] => 3
    [3] => 4
    [4] => 5
    [5] => 6
    [6] => 7
    [7] => 8
    [8] => 9
    [9] => 10
    [10] => 11
    [11] => 12
    )
    foreach($months as $month)
    {
    $monthName = date("F", mktime(0,0,0,$month,10)); // This function DATE() creates and Formats a date... since we dont care about an actual date but only a partial of a date, specifically the name of the month based on its numeric representation, we can generate a partial DATE containing the NAME of the month only... thats what "F" flag represents...
    echo "Month #{$month} is known as {$monthName} "; // Here is simply substitutes values for variables as the loop is processed...
    }
    This is the output of the loop:
    ---
    Month #1 is known as January
    Month #2 is known as February
    Month #3 is known as March
    Month #4 is known as April
    Month #5 is known as May
    Month #6 is known as June
    Month #7 is known as July
    Month #8 is known as August
    Month #9 is known as September
    Month #10 is known as October
    Month #11 is known as November
    Month #12 is known as December
    ---
    This is a much more efficient way to generate lists... you can wrap this code in a function and reuse it wherever you have forms with month selects or whatever... You can easily extend this to be multi lingual, etc...

  • @mdarifulislam1044
    @mdarifulislam1044 4 года назад

    Amazing video

  • @narsimhanarsimha7932
    @narsimhanarsimha7932 4 года назад

    Excellent

  • @topmoviescene9019
    @topmoviescene9019 4 года назад +1

    thank you

  • @mauricemakesmovies
    @mauricemakesmovies 4 года назад

    I'm uncertain whether you're still active on RUclips, but you have a great way of explaining and your voice is also relaxing to listen to. I hope you keep uploading, very helpful and clear tutorials!

    • @phpBasics
      @phpBasics  4 года назад +1

      Greetings! I am still very active helping visitors with their projects. I simply have not had an opportunity to upload anything lately, but have a lot of great content coming soon.

    • @mauricemakesmovies
      @mauricemakesmovies 4 года назад

      @@phpBasics Thanks for your fast reply. I subscribed anyway just in case 🤗

  • @theepicdot
    @theepicdot 5 лет назад +1

    Love your videos and your explanations, am a complete php novice but with your videos, am sure to get it right in my journey as a PDP beginner

  • @UnnamedUnnamed-em3gj
    @UnnamedUnnamed-em3gj 4 года назад +1

    You deserve sub bro.

  • @cricket360-sh
    @cricket360-sh 4 года назад

    Simple and easy. Thank you

  • @awaisxwati3459
    @awaisxwati3459 5 лет назад +1

    thanks sir its very easy and simple trick so please make more php foreach loop tutorial thanks

  • @shetuamin
    @shetuamin 4 года назад

    Thanks.

  • @mphomanaka2263
    @mphomanaka2263 3 года назад

    Powerful, very insight and jejune... just subscribed and think am gonna learn more from you ❤️🔥👊

  • @mayankpandey6051
    @mayankpandey6051 4 года назад

    good explaining thanks.

  • @syediqbalahmed3176
    @syediqbalahmed3176 5 лет назад

    nice ...

  • @faiezahmedkhan
    @faiezahmedkhan 5 лет назад

    great video you should make more video

  • @yagami5160
    @yagami5160 6 лет назад

    Thanks a lot, best wishes and good explaining

  • @bestoffer5054
    @bestoffer5054 5 лет назад

    this is magic great job

  • @subhashchaudhary
    @subhashchaudhary 7 лет назад

    i really like this video very much ,,, keep posting video like this ,,,i really ove to watch and we will keep sharing this ...

  • @rimantasdanilevicius6754
    @rimantasdanilevicius6754 6 лет назад

    Good and time saving php tricks, thanks!

  • @FGj-xj7rd
    @FGj-xj7rd 3 года назад

    This is some serious gourmet shit.

  • @nesyourys3766
    @nesyourys3766 4 года назад

    It's very effective

  • @abdiag603
    @abdiag603 2 года назад

    What if the value of y and x are not same e.g x

  • @shagiwal100
    @shagiwal100 7 лет назад +1

    it's very helpful tutorial, especially the last table which you created...

  • @Little_Grey_Cells
    @Little_Grey_Cells 6 лет назад

    I like this tricks. .expected more

  • @nazirulaliff5513
    @nazirulaliff5513 6 лет назад

    Sir, you're my hero! Subscribed!

  • @najeebalishah9896
    @najeebalishah9896 6 лет назад

    sir an awosome lecture to play with for loop...
    Kindly make a lecture on how to play with mysqli queries...that would be great!!!

  • @sujeewakrishanthagamage2459
    @sujeewakrishanthagamage2459 6 лет назад

    Thank you soooooooooooooooooooooooooooooooooooooo much!

  • @janezklun
    @janezklun 7 лет назад

    Good one

  • @sujitkumarsoren7646
    @sujitkumarsoren7646 7 лет назад

    Nice👍

  • @inquisitive35
    @inquisitive35 8 лет назад

    wonderful!

  • @gomo8651
    @gomo8651 6 лет назад

    Eurekah!...thanks mate :)

  • @pianoLee-sx9dx
    @pianoLee-sx9dx 6 лет назад

    I have the following code and I am trying to give the user a sticker everytime they enter something into the database.. This does work but how would I reset the counter? if they have already received 5 stickers and I want the sticker to start again at the beginning of a page, I tried to do something like this but it keeps looping...
    for ($i = 1; $i

  • @Drumronron
    @Drumronron 6 лет назад

    Thank you! :-)

  • @MrGilly
    @MrGilly 6 лет назад

    Instead of doing a FOR loop for the months array you can just use a for each loop.

  • @KhaledQweder
    @KhaledQweder 7 лет назад +1

    1000 Like.

  • @mardyart
    @mardyart 3 года назад

    It was a good video and I watched it all the way through. But I was disappointed. It said 'tricks' but these are just standard practice for loops. I though you were gonna show some wizardry I'd never seen before. Still gets a thumbs up from me even if it is 5 years old.

  • @temitopeolaoluwa
    @temitopeolaoluwa 2 года назад

    Where are the comments. The code ain't working

    • @phpBasics
      @phpBasics  2 года назад

      which part

    • @temitopeolaoluwa
      @temitopeolaoluwa 2 года назад

      @@phpBasics the array with forloop. I created an array with number ranges '1-5', '6-10' and so on but it her responds

  • @MyCity4You
    @MyCity4You 7 лет назад +2

    x+1

  • @WaRKinG15
    @WaRKinG15 5 лет назад

    really basic php stuff