FREE PHP Scripts and Snippets

Ready to use Free PHP scripts and snippets to use in your projects.
All Free Scripts & Snippets Complete PHP Scripts

Extracting all numbers from a String [PHP]

>> Share on Facebook & Impress your friends <<

This PHP function extracts all numbers from a String and prints them as a comma separated list of numbers. Ready to use function to use in your PHP Scripts and projects.

<?php

function extractAllNumbersFromString($string)
{


preg_match_all('!\d+!', $string, $matches);
$list = implode(',', $matches[0]); 

return $list;



}  // End of function for "Extracting all numbers from a String"




// Using the function to Extract all numbers from a String
// Put your test string here
$URL="This is text with 10 27 45 and something else like 5 and 7.";
echo extractAllNumbersFromString($URL)


?>


Request Custom Snippet

Just $5 Onwards

 

Previously Ordered Snippets

I want code to extract all URLs from given text.
Price $5 Order Now

I want PHP script to extract text between two delimiters.
Price $5 Order Now

I want to extract all proxy IP addresses with port id in the format ip:port_number from a text file.
Price $5 Order Now

Random PHP Scripts and Snippets

Extracting all numbers from a String [PHP]

This PHP function extracts all numbers from a String and prints them as a comma separated list of numbers. Ready...

PHP Code to list all files in a folder

This PHP Code snippet lists all files in a folder and hyperlinks them accordingly. Very clean, easy to use function....

Detect Valid Email address with PHP

A very simple php snippet to check if an email id is valid or not. If the email address is...

Free PHP folder to gallery script

100% Free PHP folder to gallery script. Just give the name of folder and it will generate gallery of all...

[PHP] Time ago calculation function

It is a very nice PHP time ago function. You gave pass any date to it and it will tell...

Create URL Slug from text string [PHP]

PHP Script to create URL from string. It retails only URL Safe characters in the strings. So, now easily create...

PHP - Extract all links from a web page

PHP Script to extract all links from a web page. This PHP Snippet reads the contents of a web page...

Make URLs in plain text clickable [PHP]

This is a simple PHP function to parse text provided and automatically hyperlink the links in the text.