Posts

Showing posts with the label append

A three-line guestbook in PHP

Below you can see a short script that causes to write somthing you enter a form to a file. Each entry is appended in new line. <form method=post><input name=a><input type=submit></form> <?php if($_POST['a'])file_put_contents('z.txt',$_POST['a']."\n",FILE_APPEND);

How to incrase a variable by given value ?

You can incrase a varaible value by number by += operator. If you want to incrase string by appending some data at the end, then use .= operator.See examples below: $number += 10; $string .= " and something";

PHP Array add element - how to append element to an array

If you have a PHP array and wants to add element to it, you can do it just in this way: $myArray[] = 'new element'; This will add element to php array at its end