PHP Code Snippets


Some PHP functions and code snippets useful for PHP Programmers and scripts.
New PHP Code Snippets might be added soon.

  1. Get Time Elapsed
  2. Interpret / Parse / Replace variable in string with value
  3. Delete multiple consecutive characters and Split long words
  4. Force Download-files with PHP
  5. innerHTML in PHP
  6. Keep the first Nr IMG tags, Strip all the others
  7. Convert XML to JSON in PHP
  8. Get the Timestamp of First and Last day of Month
  9. Create Array of Unique Random Numbers or Letters
  10. Image in PHP with background in two colors
  11. Sort an entire multi-dimensional Array
  12. Merge Multiple Files, Line by Line
  13. Dynamically PHP Maps with Rectangle, Parallelogram, and Rhomb Shapes
  14. Chaining Static and Public Methods
  15. Recursive function to create Multi-Level Menu in PHP
  16. XML sitemap with data from MySQL
  17. Split an alphanumeric string into Array
  18. Save image on server from external URL
  19. Get visitor IP
  20. PHP Image with text on New Lines
  21. Get all the unique numbers from two-dimensional array
  22. Get Closest Number
  23. Get Lower, Higher, and Closest Number
  24. Create ZIP file archive with PHP
  25. Extract / Unzip ZIP archive files with PHP
  26. Read ZIP archive data with PHP
  27. Get the difference between two Dates - Time and Date
  28. Calculate the Age
  29. Zodiac Signs PHP code