PHP Code Snippets

perra77

Find characters in string

Read more

David Carr

This will remove all non-integer characters, including commas and currency symbols. The output is a float.

Read more

David Carr

This snippet is useful for calculating the length of a playlist. 2 videos at 5 min 45secs each would give 11:30 total play time.

Read more

David Carr

For situations where an image is stored inside a WYSIWYG editor you cannot pass that directly an img tag instead you need to extract the source path inside the <img src=''> tags. This can be done by using this regular expression.

Read more

David Carr

This snippet looks inside a $content variable and looks for all img tags and extracts the src path and created a new img tag from them. This allows classes to be added to images.

Read more

David Carr

This function is used to copy a folder and all its contents and sub folders, its params are as follows:

1) The source folder path
2) The destination path (should not exist)

Read more

David Carr

This function is used to rename all instances of a word in a file.

Pararms are as follows:
1) Path to the file
2) The name to rename
3) The new name to be used

Read more

daok

This class deletes a directory along with its contents no matter how deep/nested its sub-directories are.

Read more

Copyright © 2011 - 2018 created by David Carr Web Developer. All code MIT license. All rights reserved. Built using Simple MVC Framework