Avatar of bachstein
bachstein

asked on 

extract number out of a sytle attribute

Hello

Could someone help me with this? I want to get the number out of a style width rule, for instance

if I have
style="width120px"; 

Open in new window


I want to get that 120 . I have the string in my PHP code.

like this
$var = 'style = "width:120px" ';

Open in new window

so basically what I want is to take this variable $var apply a regular expression to it ,  and the the 120 back


Cheers



 
PHP

Avatar of undefined
Last Comment
bachstein
ASKER CERTIFIED SOLUTION
Avatar of Tyler Laczko
Tyler Laczko
Flag of Canada image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
Avatar of Tyler Laczko
Tyler Laczko
Flag of Canada image

That will strip anything that isn't 0-9
Avatar of Tyler Laczko
Tyler Laczko
Flag of Canada image

sorry i should rephrase my previous post. this will strip anything that isnt 0-9 per character comparison.

456456 would still be recognized.
Avatar of bachstein
bachstein

ASKER

It worked. Thanks.
PHP
PHP

PHP is a widely-used server-side scripting language especially suited for web development, powering tens of millions of sites from Facebook to personal WordPress blogs. PHP is often paired with the MySQL relational database, but includes support for most other mainstream databases. By utilizing different Server APIs, PHP can work on many different web servers as a server-side scripting language.

125K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo