Remove Array Element and Re-index in PHP

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

282 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

707 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

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

Get Numeric Index of Associative Array in PHP

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

943 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

Get File Name from a Path in PHP

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

897 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

Get Current Function Name in PHP

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

673 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"

Delete Array Element Based on Key in PHP

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

778 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

Zip Entry Read Function in PHP

karthikeya Boyini
Updated on 27-Dec-2019 07:29:57

110 Views

The zip_entry_read() function is used to get the contents from an open zip archive file.Syntaxzip_entry_read(zip_entry, len)Parameterszip_entry − The zip entry resource. Required.len − The length in bytes. The default is 1024.ReturnThe zip_entry_read() function Returns the contents from an open zip archive file. Returns FALSE on failure.ExampleThe following is an example. Let’s say our zip file "one.zip" is having only a single file i.e. "detail.txt" with the following content.Asia is a continent!Let us see an example −ExampleOutputText in the file = Asia is a continent!Read More

Search for Particular Strings in Comma-Separated Values in MySQL

AmitDiwan
Updated on 27-Dec-2019 07:11:07

640 Views

For this, use REGEXP. Let us first create a table −mysql> create table DemoTable1902    (    Subjects text    ); Query OK, 0 rows affected (0.00 sec)Insert some records in the table using insert command −mysql> insert into DemoTable1902 values('MongoDB, Java, Python'); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1902 values('SQL Server, MySQL, PL/SQL'); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1902 values('Hibernate, Spring, JPA'); Query OK, 1 row affected (0.00 sec)Display all records from the table using select statement −mysql> select * from DemoTable1902;This will produce the following output −+-------------------------+ | Subjects ... Read More

Copy Records Between MySQL Tables with Different Columns

AmitDiwan
Updated on 27-Dec-2019 07:09:41

692 Views

For this you can use INSERT INTO SELECT statement. Let us first create a table −mysql> create table DemoTable1900    (    ClientId int NOT NULL AUTO_INCREMENT PRIMARY KEY,    ClientName varchar(20),    ClientAge int default 29    ) auto_increment=1000; Query OK, 0 rows affected (0.00 sec)Insert some records in the table using insert command −mysql> insert into DemoTable1900(ClientName, ClientAge) values('Chris', 45); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1900(ClientName, ClientAge) values('David', 29); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1900(ClientName, ClientAge) values('Mike', 37); Query OK, 1 row affected (0.00 sec) mysql> insert into ... Read More

Advertisements