Sorry, I can't reply yet to the first comment, but the above solution is not working correctly if the last day of month have in first week of new year (test case: 2019-12-01).
I made a quick fix (based on original code):
// Input date format: YYYY-mm-dd
function getMonthWeekNumbers( $first_date )
{
$last_date = date( "Y-m-t",strtotime( $first_date ) );
$first_week = date( "W",strtotime( $first_date ) );
$last_week = date( "W",strtotime( $last_date ) );
// If last day of month have on first week on next year, subtract a week from the date
if( $last_week == '01' )
{
$last_week = date( "W",( strtotime( $last_date )-604800 ) );
}
for( $i=$first_week; $i <= $last_week; $i++ )
{
echo "Week #".$i.", ";
}
}
It working fine with any input dates.
DEMO