Found 26504 Articles for Server Side Programming

What is the use of the @ symbol in PHP?

AmitDiwan
Updated on 26-Dec-2019 10:22:43

1K+ Views

PHP supports the error control operator i.e. the at sign (@). When @ is prepended to an expression, any error messages that might be generated by that expression gets ignored.To use @ symbol in PHP, the code is as follows−Example Live Demo

Convert an object to associative array in PHP

AmitDiwan
Updated on 26-Dec-2019 10:20:05

447 Views

To convert an object to associative array in PHP, the code is as follows−Example Live DemoOutputThis will produce the following output−Before conversion: object(department)#1 (2) {    ["deptname"]=>    string(9) "Marketing"    ["deptzone"]=>    string(5) "South" } After conversion: array(2) {    ["deptname"]=>    string(9) "Marketing"    ["deptzone"]=>    string(5) "South" }ExampleLet us now see another example − Live DemoOutputThis will produce the following output−Before conversion: object(department)#1 (2) {    ["deptname"]=>    string(9) "Marketing"    ["deptzone"]=>    string(5) "South" } After conversion: array(2) {    ["deptname"]=>    string(9) "Marketing"    ["deptzone"]=>    string(5) "South" }

PHP program to change date format

AmitDiwan
Updated on 26-Dec-2019 10:16:47

136 Views

To change date format in PHP, the code is as follows−Example Live DemoOutputThis will produce the following output−Displaying date... Date = 2019-11-11 05:25 PM Displaying updated date...  2019-12-01 17:25ExampleLet us now see another example− Live DemoOutputThis will produce the following output−Displaying date... 2019/11/11 00:00:00

PHP program to add item at the beginning of associative array

AmitDiwan
Updated on 26-Dec-2019 10:15:13

321 Views

To add an item at the beginning of the associative array, the code is as follows−Example Live DemoOutputThis will produce the following output−Initial Array... Array(    [p] => 150    [q] => 100    [r] => 120    [s] => 110    [t] => 115    [u] => 103    [v] => 105    [w] => 125 ) Updated Array... Array (    [0] => 100    [p] => 150    [q] => 100    [r] => 120    [s] => 110    [t] => 115    [u] => 103    [v] => 105    [w] => 125 )ExampleLet us now see another example− Live DemoOutputThis will produce the following output−Initial Array... Array(    [0] => Ryan    [1] => Kevin    [2] => Jack ) Updated Array... Array(    [0] => Katie    [1] => Ryan    [2] => Kevin    [3] => Jack )

Double not (!!) operator in PHP

AmitDiwan
Updated on 26-Dec-2019 10:12:09

480 Views

In the Double not operator (!!), the first not i.e. ! is used to negate a value, whereas the second not i.e.! again negates. To implement Double not operator in PHP, the code is as follows−Example Live DemoOutputThis will produce the following output−Value = 0.1 Double Negated Value = 1ExampleLet us now see another example − Live DemoOutputThis will produce the following output−String = 100.56 Number (Converted from String) = 100.56 Double Negated Value = 1

How to convert a string into number in PHP?

AmitDiwan
Updated on 26-Dec-2019 10:10:34

277 Views

To convert a string into a number, the code is as follows−Example Live DemoOutputThis will produce the following output−Number (Converted from String) = 150ExampleLet us now see another example− Live DemoOutputThis will produce the following output−String = 100.56 Number (Converted from String) = 100.56

How to convert number to month name in PHP?

AmitDiwan
Updated on 26-Dec-2019 10:08:01

3K+ Views

To convert number to month name in PHP, the code is as follows−Example Live DemoOutputThis will produce the following output−Displaying date... Date = 2019-11-11 Month = November Displaying updated date... 2019-12-01ExampleLet us now see another example − Live DemoOutputThis will produce the following output −Displaying date... Date = 2019-11-11 Month = November Displaying updated date... 2019-12-01 Month = December

How to create comma separated list from an array in PHP?

AmitDiwan
Updated on 26-Dec-2019 10:05:44

2K+ Views

To create a comma-separated list from an array in PHP, the code is as follows−Example Live DemoOutputThis will produce the following output−Array with leading and trailing whitespaces... Value = John Value = Jacob Value = Tom Value = Tim Comma separated list...    John , Jacob , Tom , Tim Updated Array... Value = John Value = Jacob Value = Tom Value = TimExampleLet us now see another example − Live DemoOutputThis will produce the following output−Comma separated list... 100, 200, 300, 400, 500

How to get a variable name as a string in PHP?

AmitDiwan
Updated on 26-Dec-2019 10:03:02

2K+ Views

To get a variable name as a string in PHP, the code is as follows−Example Live DemoOutputThis will produce the following output−This is it!ExampleLet us now see another example − Live DemoOutputThis will produce the following output−Val

How to re-index an array in PHP?

AmitDiwan
Updated on 26-Dec-2019 08:04:03

775 Views

To re-index an array in PHP, the code is as follows −Example Live DemoOutputThis will produce the following output−Array... Key = 0, Value = 150  Key = 1, Value = 100 Key = 2, Value = 120 Key = 3, Value = 110 Key = 4, Value = 115 Array after re-indexing Key = 2, Value = 150 Key = 3, Value = 100 Key = 4, Value = 120 Key = 5, Value = 110 Key = 6, Value = 115ExampleLet us now see another example − Live DemoOutputThis will produce the following output−Array... Key = a, Value = 150 Key = b, Value = 100 Key = c, Value = 120 Key = d, Value = 110 Key = e, Value = 115 Array after re-indexing Key = b, Value = 150 Key = c, Value = 100 Key = d, Value = 120 Key = e, Value = 110 Key = f, Value = 115

Advertisements