Jump to content

[SOLVED] Get the fist number froma string?


farkewie

Recommended Posts

Hey ive seen it somewhere but i just cant find it..

 

i need to read a string of nine numbers and depending on the value of the first number set a variable saying if it is 3g or not

 

ie.

<?php

if ($phone_row['sim'] starts with 5 or higher) { $network = "3G / Next G";}

else if ($phone_row['sim'] starts with 4 or lower) { $network = "GSM"; }

?>

Link to comment
Share on other sites

Without bench marking it... regular expression is not as efficienct as the method kratsg suggested for the simple fact it has to run the regex engine on a string.

 

If you KNOW the firts value of the 'string' is the piece of data you need then its much more efficient to isolate that piece of data without the use of a regular expression.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.