php


How to get specific substring digit from string using php? [duplicate]


This question already has an answer here:
Extract numbers from a string
11 answers
$fileName = "Backup_1486874341.tar.gz"
Here is my file name. How can i get only timestamp from that file name Like 1486874341
Use simple regex in preg_match() to select target digit in file name.
$fileName = "Backup_1486874341.tar.gz";
preg_match("/_(\d+)./", $fileName, $matches);
echo $matches[1];
See result in demo
Here is the sample snippet:
<?php
$str = 'Backup_1486874341.tar.gz';
preg_match_all('!\d+!', $str, $matches);
print_r($matches[0][0]);
?>

Related Links

MySQL Syntax Error, (1064)
html php contact form - attachement not available
MySQL Syntax not returning result
Sending variable by ajax in use of laravel
Unable to make join query in mysql or my table structure is wrong
How can I query in laravel from a column in the db that has single values and arrays?
Setting up pyrocms/codeigniter on localhost
Sending Mail in php from localhost
Can't get PDFMerger.php to work with an interface
Disable submit button when value in input field is already in database
How to create empty rows on user creation in codeigniter
PHP memory_get_peak_usage is showing different for development server and production server
php password check with hash doesn't work
How to set wordpress theme in code
Radio button groups generated with TcPDF cutting off in adobe reader
Codeigniter Email Libraries - Undefined property: stdClass::$email

Categories

HOME
cocoapods
office365
visual-studio
adfs3.0
couchdb
bots
message-queue
website
openlayers-3
portable-class-library
swift2
haxe
stored-procedures
phpseclib
kurento
azure-logic-apps
driver
getopenfilename
csrf
texas-instruments
nest-api
c#-7.0
exec-maven-plugin
checkout
spam
jest
opentext
high-availability
unrar
django-import-export
sfml
fusion
guice
caesar-cipher
android-canvas
telephonymanager
ng-repeat
windows-store
export-to-pdf
flowchart
oauth2-playground
access-denied
vungle-ads
contactless-smartcard
ssi
android-5.0-lollipop
simple-schema
nslayoutconstraint
network-protocols
lvalue
1010
pecl
gawk
streamwriter
xcode6.4
coovachilli
persistent-object-store
django-validation
linuxbrew
perceptron
auto-generate
espresso
wlanapi
sequence-sql
artisan
ocmockito
hp-idol-ondemand
iodocs
category-theory
spring-security-acl
facebook-game-groups
pbkdf2
notin
itunes-sdk
icenium
user-forums
system-requirements
gitx
zend-pdf
viewpagerindicator
first-class
jdom
kolite
zend-server-ce
haiku
android-2.1-eclair
chunking
resharper-5.1
getimagesize
powergui
.net-client-profile
main-method
activex-exe
error-detection

Resources

Encrypt Message