## Improve php programming skills

Here we have bunch of task improving php programming, this kind of program always make in C, C++, java and c#, now to time implement in PHP programming

TASK 1:Print triangle number in reverse pattern

Need output like below
6 5 4 3 2 1
5 4 3 2 1
4 3 2 1
3 2 1
2 1
1

```1 2 3 4 5 6 7 8 9 10 11 <?php for(\$i=6;\$i>=1;\$i--) { for(\$j=\$i;\$j>=1;\$j--){ echo \$j." "; if(\$j==1){ echo "<br/>"; } } } ?>```

TASK 2:Print triangle number

Need output like below
1
1 2
1 2 3
1 2 3 4
1 2 3 4 5
1 2 3 4 5 6

```1 2 3 4 5 6 7 8 9 10 <?php for(\$i=1;\$i<=6;\$i++){ for(\$j=1;\$j<=\$i;\$j++){ echo \$j." "; if(\$j==\$i){ echo "<br/>"; } } } ?>```

TASK 3:Floyd triangle number

Need output like below
1
2 3
4 5 6
7 8 9 10
11 12 13 14 15
16 17 18 19 20 21

```1 2 3 4 5 6 7 8 9 10 11 12 <?php \$num=1; for(\$i=1;\$i<=6;\$i++){ for(\$j=1;\$j<=\$i;\$j++){ echo \$num." "; \$num++; if(\$j==\$i){ echo "<br/>"; } } } ?>```

TASK 4:Print triangle number in reverse pattern

Need output like below
1
2 1
3 2 1
4 3 2 1
5 4 3 2 1
6 5 4 3 2 1

```1 2 3 4 5 6 7 8 9 10 <?php for(\$i=1;\$i<=6;\$i++){ for(\$j=\$i;\$j>=1;\$j--){ echo \$j." "; if(\$j==1){ echo "<br/>"; } } } ?>```

Need output like below
—–1
—-2 2
—3 3 3
–4 4 4 4 4
-5 5 5 5 5 5

```1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 <?php for(\$i=1;\$i<=5;\$i++){ for(\$k=5;\$k>=\$i;\$k--) { echo "-"; } for(\$j=1;\$j<=\$i;\$j++) { echo \$i." "; if(\$j==\$i){ echo "<br/>"; } } } ?>```

## Why The Array Index Start From Zero in Progamming Language

Hello Friend one day i was studying Array in Php.

i have found something about array

An array stores multiple values in one single variable.
An array is a special variable, which can hold more than one value at a time.

In PHP, there are three types of arrays:

Indexed arrays – Arrays with numeric index
Associative arrays – Arrays with named keys
Multidimensional arrays – Arrays containing one or more arrays

After that one question came in my mind Why The Array Index Start From 0 Not 1 so i m totally confused taking to it then i start Google, i have found some interesting topics about it, now sharing with you all my programmer friends-

Example in C programming language

The discussion over why the array index should start at zero is not a trivial one and relates to interesting concepts from computer science. First of all, it has strong relation to language design. For example in C, the name of an array is essentially a pointer, a reference to a memory location, and so the expression array[n] refers to a memory location n-elements away from the starting element. This means that the index is used as an offset. The first element of the array is exactly contained in the memory location that array refers (0 elements away), so it should be denoted as array[0]. Most programming languages have been designed this way, so indexing from 0 is pretty much inherent to the language.Read More

i have found many more topic related to it sharing those below links

## Adding a custom field to all existing posts in WordPress

I found a way make custom field all existing posts. If you can access the MySQL admin interface, only just run the following query on the WordPress database:

```1 2 3 4 INSERT INTO wp_postmeta (post_id, meta_key, meta_value) SELECT wp_posts.ID, 'image_value', '{image}' FROM wp_posts WHERE wp_posts.post_status = 'publish';```

The only thing you might need to change is the WHERE condition. The SQL statement as written above will add that custom field to all published posts.