Found 1060 Articles for PHP

How to remove the first character of string in PHP?

AmitDiwan
Updated on 27-Dec-2019 07:53:32

2K+ Views

To remove the first character of a string in PHP, the code is as follows−Example Live DemoOutputThis will produce the following output −Before removing the first character = Test After removing the first character = estExampleLet us now see another example Live DemoOutputThis will produce the following output−Before removing the first character = Demo After removing the first character = emo

Removing Array Element and Re-Indexing in PHP

AmitDiwan
Updated on 27-Dec-2019 07:49:34

265 Views

To remove an array element and re-index the array, 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 = Tim Updated Array...Re-indexed Value = John Value = Tom Value = Tim

Remove new lines from string in PHP

AmitDiwan
Updated on 27-Dec-2019 07:47:05

676 Views

To remove newlines from the string, the code is as follows−Example Live DemoOutputThis will produce the following output−Demo     text for reference Demo text for referenceExampleLet us now see another example − Live DemoOutputThis will produce the following output−Demo     text Demo text

How to get parameters from a URL string in PHP?

AmitDiwan
Updated on 27-Dec-2019 07:42:54

5K+ Views

To get parameters from a URL string in PHP, the code is as follows−Example Live DemoOutputThis will produce the following output−Email = example12@domain.comExampleLet us now see another example − Live DemoOutputThis will produce the following output−Email = demo

How to get numeric index of associative array in PHP?

AmitDiwan
Updated on 27-Dec-2019 07:39:23

916 Views

To get the numeric index of an associative array, the code is as follows−Example Live DemoOutputThis will produce the following output−Array key and value... key: a, value: 5 key: b, value: 20 key: c, value: 35 key: d, value: 55ExampleLet 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: 120 key: s, value: 25

How to get file name from a path in PHP?

AmitDiwan
Updated on 27-Dec-2019 07:36:26

877 Views

To get the file name from a path, the code is as follows−Example Live DemoOutputThis will produce the following output−main.phpExampleLet us now see another example − Live DemoOutputThis will produce the following output−main

How to get current function name in PHP?

AmitDiwan
Updated on 27-Dec-2019 07:34:12

637 Views

To get the current function name in PHP, the code is as follows−Example Live DemoOutputThis will produce the following output−Base class function! Base class function declared final!string(7) "display" Derived class function! Base class function declared final!string(7) "display"ExampleLet us now see another example − Live DemoOutputThis will produce the following output−Base class function!string(10) "Base::demo" Base class function declared final!string(7) "display" Derived class function! Base class function declared final!string(7) "display"

How to delete an array element based on key in PHP?

AmitDiwan
Updated on 27-Dec-2019 07:30:56

755 Views

To delete an array element based on a key 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 = Tim Updated Array... Value = John Value = Tom Value = TimExampleLet us now see another example − Live DemoOutputThis will produce the following output. Now, an error would be visible since we deleted the element and trying to ... Read More

Function Overloading and Overriding in PHP

AmitDiwan
Updated on 02-Jan-2020 06:36:33

13K+ Views

Function Overloading in PHPFunction overloading is a feature that permits making creating several methods with a similar name that works differently from one another in the type of the input parameters it accepts as arguments.ExampleLet us now see an example to implement function overloading− Live DemoOutputThis will produce the following output−9.42648Function Overriding in PHPIn function overriding, the parent and child classes have the same function name with and number of argumentsExampleLet us now see an example to implement function overriding− Live DemoOutputThis will produce the following output−Base class function! Base class function declared final! Derived class function! Base class function declared final!Read More

Generating Random String Using PHP

AmitDiwan
Updated on 26-Dec-2019 10:39:42

337 Views

To generate random string using PHP, the code is as follows−Example Live DemoOutputThis will produce the following output−Displaying random string... 1c856ExampleLet us now see another example − Live DemoOutputThis will produce the following output−Displaying random string... a3541 Displaying another random string... 335b83d9e9

Advertisements