
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Found 1060 Articles for PHP

471 Views
To access an associative array by integer index in PHP, the code is as follows−Example Live DemoOutputThis will produce the following output−Array key and value... key: p, value: 150 key: q, value: 100 key: r, value: 120 key: s, value: 110ExampleLet us now see another example− Live DemoOutputThis will produce the following output−Array key and value... key: p, value: 150 key: q, value: 100 key: r, value: 120 key: s, value: 110 Updated Array key and value... key: p, value: 150 key: q, value: 100 key: r, value: 20 key: s, value: 10

126 Views
To create a copy of an object in PHP, the code is as follows−Example Live DemoOutputThis will produce the following output−JackKevin TomRyanExampleLet us now see another example − Live DemoOutputThis will produce the following output−Demo Object( [deptname] => Finance [deptzone] => West ) Demo Object( [deptname] => Finance [deptzone] => West )

1K+ Views
A global variable can be accessed in any part of the program. However, in order to be modified, a global variable must be explicitly declared to be global in the function in which it is to be modified. This is accomplished, conveniently enough, by placing the keyword GLOBAL in front of the variable that should be recognized as global.ExampleThe code is as follows wherein we can see how to declare a global variable in PHP− Live DemoOutputThis will produce the following output−Value = 2ExampleLet us now see another example− Live DemoOutputThis will produce the following output−5

183 Views
To merge two arrays keeping original keys in PHP, the code is as follows−Example Live DemoOutputThis will produce the following output−array(8) { ["p"]=> string(3) "150" ["q"]=> string(3) "100" ["r"]=> string(3) "120" ["s"]=> string(3) "110" ["t"]=> string(3) "115" ["u"]=> string(3) "103" ["v"]=> string(3) "105" ["w"]=> string(3) "125" }ExampleLet us now see another example − Live DemoOutputThis will produce the following output−array(1) { ["a"]=> string(5) "Jacob" }

445 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" }

134 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

318 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 )

477 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