All months in string format not showing correctly using foreach in php


South Africa

Below I use a foreach loop to just print all the months like January to December

foreach(range(1,12) as $i)
{
 echo $pmoth =date("F", mktime(0,0,0,$i));
}

See screenshots: March shows in screenshots instead of February

enter image description here

Desai

Finally, passing the date parameter also requires the current date (30), so for February it is not a valid date. That's why it shows march

foreach(range(1,12) as $i)
{
 echo $pmoth =date("F", mktime(0,0,0,$i,1));
}

Related


PHP DatePeriod not showing all months

ralph doll When executing the code below, PHP only displays the 10th and 12th months, ignoring the 11th month entirely. $sollStart = '2019-10-31 00:00:01'; $sollEnde = '2019-12-31 23:59:59'; $start = new DateTime($sollStart); $end = new DateTim

Correctly format email string using python

Pucho I have a piece of code that extracts email addresses from a list and adds them to the "To" field of a MIME service. Due to the wrong email list, only the first recipient will receive the email. The "list.csv" file looks like this [email protected] jean

php remove all css from string not showing

Peter Cullen I have an html string with CSS, similar to this: <div style="display: none; someotherstyle: freaky; etc ..."> Some Content </div> I want to process a string in PHP to remove all instances ofdisplay: none; But I also like to compensate for thi

All months are not showing in D3

Arvind Suryanarayana Code: var margin = {top: 30, right: 40, bottom: 30, left: 50}, width = 600 - margin.left - margin.right, height = 270 - margin.top - margin.bottom; var parseDate = d3.time.format("%b").parse; var formatTime = d3.time.format("%B");

Unable to format string correctly

咕 噜 咕 噜 (Raspberry Pi, rp3) I can send a string to my GUI (tkinter) from the PC console. one example: $SK039AR878HT010; (I sent this command manually from the console to test, but in the future my console will be replaced by a machine) This command basically m

String format is used correctly

Isaac Do you know of another more appropriate way of doing the same thing? string initialTemplate = "{0}-{1}"; string template = string.Format(initialTemplate, "first", "{0}"); string answer = string.Format(template, "second"); Again, the following method is

String format is used correctly

Isaac Do you know of another more appropriate way of doing the same thing? string initialTemplate = "{0}-{1}"; string template = string.Format(initialTemplate, "first", "{0}"); string answer = string.Format(template, "second"); Again, the following method is

Format numbers correctly in php

username I am trying to format 2176to 21.76php I have the following code:$Payment->amount equals 2176 in this example. $<?php echo number_format($Payment->amount,'2')/100; ?> I understand 0.02why? xdazz number_format($Payment->amount,'2')gives you the string

PHP session not showing correctly in terminal

Zoric I'm currently building a small script for a cron job, I'm testing everything in the terminal (Linux), but I can't figure out why the session isn't working. session_start() $_SESSION['cron'] = 'test'; echo $_SESSION['cron']; Zoric Here is my solution pri

Google Chart vAxis format not showing % correctly

Jett Please find the Google column chart in my code: <html> <head> <title>Test</title> <link rel='stylesheet' href='https://cdnjs.cloudflare.com/ajax/libs/normalize/8.0.1/normalize.min.css'> <link href='https://fonts.googleapis.com/css?fam

Google Chart vAxis format not showing % correctly

Jett Please find the Google column chart in my code: <html> <head> <title>Test</title> <link rel='stylesheet' href='https://cdnjs.cloudflare.com/ajax/libs/normalize/8.0.1/normalize.min.css'> <link href='https://fonts.googleapis.com/css?fam

Google Chart vAxis format not showing % correctly

Jett Please find the Google column chart in my code: <html> <head> <title>Test</title> <link rel='stylesheet' href='https://cdnjs.cloudflare.com/ajax/libs/normalize/8.0.1/normalize.min.css'> <link href='https://fonts.googleapis.com/css?fam

Google Chart vAxis format not showing % correctly

Jett Please find the Google column chart in my code: <html> <head> <title>Test</title> <link rel='stylesheet' href='https://cdnjs.cloudflare.com/ajax/libs/normalize/8.0.1/normalize.min.css'> <link href='https://fonts.googleapis.com/css?fam

Popup using javascript not showing correctly

username I've done 2 web related classes and made a similar project in a popup using html and javascript, but the problem is that the popup doesn't show at all or it shows for half a second and closes immediately. I can't post the whole code, but below is the

Using foreach in foreach with PHP

Aaron So I'm using a foreachto output my output table-cells, and I'm running into a problem with my output. Here is what I am trying to achieve: <tr> <th scope="col"> <h3>Ember</h3> <p> Xeon E3-1231</p> </th> <th scope="col"> <h3>Ember</h3> <p> Xeon E3-

Using foreach in foreach with PHP

Aaron So I'm using a foreachto output my output table-cells, and I'm running into a problem with my output. Here is what I am trying to achieve: <tr> <th scope="col"> <h3>Ember</h3> <p> Xeon E3-1231</p> </th> <th scope="col"> <h3>Ember</h3> <p> Xeon E3-

Using foreach in foreach with PHP

Aaron So I'm using a foreachto output my output table-cells, and I'm running into a problem with my output. Here is what I am trying to achieve: <tr> <th scope="col"> <h3>Ember</h3> <p> Xeon E3-1231</p> </th> <th scope="col"> <h3>Ember</h3> <p> Xeon E3-

How to echo number format grouped array inside foreach using PHP?

Rzj Hayabusa My question refers to my previous question in this link How to use a foreach loop in PHP to echo a specific multiple identical records only once? . Here is my current code Code: $sqlTXT = "SELECT * FROM TABLE"; $arr_old = DB::getInstance()->Fetch

How to format Spanish months in sentences using SimpleDateFormat?

Vijin Paulraj Here is my code: /* package whatever; // don't place package name! */ import java.util.*; import java.lang.*; import java.io.*; import java.text.SimpleDateFormat; /* Name of the class has to be "Main" only if the class is public. */ class Ideon