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
Programming Articles - Page 2192 of 3366
210 Views
Both get the union of arrays, but array_merge() overwrites duplicate non_numeric keys. Let us now see an example of the array+array−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 an example of array_merge() in PHP− 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) "110" ["v"]=> string(3) "105" ["w"]=> string(3) "100" }
6K+ Views
The print and echo are both language constructs to display strings. The echo has a void return type, whereas print has a return value of 1 so it can be used in expressions. The print_r is used to display human-readable information about a variable.ExampleLet us now see an example that displays output using echo, print, and print_r: Live DemoOutputThis will produce the following output−Array... Value = John Value = Jacob Value = Tom Value = Tim Displaying Array Values using print... Value = John Value = Jacob Value = Tom Value = Tim Displaying Array Values using print_r... Array ( [0] => John [1] => Jacob [2] => Tom [3] => Tim )
3K+ Views
To return all dates between two dates, the code is as follows −Example Live DemoOutputThis will produce the following output−array(11) { [0]=> string(10) "10-11-2019" [1]=> string(10) "11-11-2019" [2]=> string(10) "12-11-2019" [3]=> string(10) "13-11-2019" [4]=> string(10) "14-11-2019" [5]=> string(10) "15-11-2019" [6]=> string(10) "16-11-2019" [7]=> string(10) "17-11-2019" [8]=> string(10) "18-11-2019" [9]=> string(10) "19-11-2019" [10]=> string(10) "20-11-2019" }
3K+ Views
To reset keys of array elements using PHP, the code is as follows−Example Live DemoOutputThis will produce the following output−array(4) { ["p"]=> string(3) "150" ["q"]=> string(3) "100" ["r"]=> string(3) "120" ["s"]=> string(3) "110" } array(4) { [0]=> string(3) "150" [1]=> string(3) "100" [2]=> string(3) "120" [3]=> string(3) "110" }ExampleLet us now see another example − Live DemoOutputThis will produce the following output−array(4) { [8]=> string(3) "Ben" [4]=> string(5) "Kevin" [7]=> string(4) "Mark" [3]=> string(5) "Hanks" } array(4) { [0]=> string(3) "Ben" [1]=> string(5) "Kevin" [2]=> string(4) "Mark" [3]=> string(5) "Hanks" }
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
273 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
686 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
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
927 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