Friday, March 20, 2020

How to Print an Array in PHP Using Print_r()

How to Print an Array in PHP Using Print_r() An array in PHP computer programming contains a group of similar objects that are the same type and size. The array can contain integers, characters, or anything else with a defined data type. The print_r PHP function is used to return an array in a human readable form. It is written as: print_r($your_array) In this example, an array is defined and printed. The tag pre indicates the following code is preformatted text. This tag causes the text to be displayed in a fixed-width font. It preserves line breaks and spaces, making it easier for the human observer to read. pre?php $Names array (a Angela, b Bradley, c array (Cade, Caleb)); print_r ($Names); ? /pre When the code is run, the results looks like this: Array([a] Angela[b] Bradley[c] Array([0] Cade[1] Caleb)) Variations of Print_r You can store the result of print_r in a variable with a second parameter to print_r. This technique prevents any output from the function. Augment the function of print_r with var_dump and var_export to show protected and private properties of the objects, including type and value. The difference of the two is that var_export returns valid PHP code, whereas var_dump does not. Uses for PHP PHP is a server-side language used to add enhanced features  to a website developed in HTML, such as surveys, shopping carts, login boxes, and CAPTCHA codes. You can use it to build an online community, integrate Facebook with your website, and generate PDF files. With PHPs file-handling functions, you can create photo galleries and you can use the GD library included with PHP to generate thumbnail images, add watermarks, and resize and crop images. If you host banner ads on your website, PHP rotates them at random.  The same feature can be used to rotate quotations. It is easy to set up page redirects using PHP and if you are wondering how often your visitors check out your website, use PHP to set up a counter.

Wednesday, March 4, 2020

Labor Unions During the Great Depression

Labor Unions During the Great Depression The Great Depression of the 1930s changed Americans view of unions. Although AFL membership fell to fewer than 3 million amidst large-scale unemployment, widespread economic hardship created sympathy for working people. At the depths of the Depression, about one-third of the American workforce was unemployed, a staggering figure for a country that, in the decade before, had enjoyed full employment. Roosevelt and the Labor Unions With the election of President Franklin D. Roosevelt in 1932, government - and eventually the courts - began to look more favorably on the pleas of labor. In 1932, Congress passed one of the first pro-labor laws, the Norris-La Guardia Act, which made yellow-dog contracts  unenforceable. The law also limited the power of federal courts to stop strikes and other job actions. When Roosevelt took office, he sought a number of important laws that advanced labors cause. One of these, the National Labor Relations Act of 1935 (also known as the Wagner Act) gave workers the right to join unions and to bargain collectively through union representatives. The act established the National Labor Relations Board (NLRB) to punish unfair labor practices and to organize elections when employees wanted to form unions. The NLRB could force employers to provide back pay if they unjustly discharged employees for engaging in union activities. Growth in Union Membership With such support, trade union membership jumped to almost 9 million by 1940. Larger membership rolls did not come without growing pains, however. In 1935, eight unions within the AFL created the Committee for Industrial Organization (CIO) to organize workers in such mass-production industries as automobiles and steel. Its supporters wanted to organize all workers at a company - skilled and unskilled alike - at the same time. The craft unions that controlled the AFL opposed efforts to unionize unskilled and semiskilled workers, preferring that workers remain organized by craft across industries. The CIOs aggressive drives succeeded in unionizing many plants, however. In 1938, the AFL expelled the unions that had formed the CIO. The CIO quickly established its own federation using a new name, the Congress of Industrial Organizations, which became a full competitor with the AFL. After the United States entered World War II, key labor leaders promised not to interrupt the nations defense production with strikes. The government also put controls on wages, stalling wage gains. But workers won significant improvements in fringe benefits - notably in the area of health insurance  and union membership soared.