PHP function to select first two values of variable

Posted on 2011-03-04
Last Modified: 2012-05-11

i need php function to select first two values of variable.


then it will pick only first two values

Question by:savsofts
  • 2
LVL 142

Accepted Solution

Guy Hengel [angelIII / a3] earned 125 total points
ID: 35034486
you mean substr:

$val = substr($val, 0,2);

Open in new window

LVL 13

Expert Comment

ID: 35034501
function extractNum($aNumber,$num){
$temp = str_split ($aNumber);


return $rtn;

Open in new window

LVL 13

Expert Comment

ID: 35034525
use substr :), assume the logic is similar the in the source

Featured Post

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
curl SSL certificate unable to get local issuer certificate 15 63
hasing a url 16 23
website maintenance mode 1 15
Which userID to use for shopping cart application 13 18
Author Note: Since this E-E article was originally written, years ago, formal testing has come into common use in the world of PHP.  PHPUnit ( and similar technologies have enjoyed wide adoption, making it possib…
I imagine that there are some, like me, who require a way of getting currency exchange rates for implementation in web project from time to time, so I thought I would share a solution that I have developed for this purpose. It turns out that Yaho…
The viewer will learn how to count occurrences of each item in an array.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

816 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

8 Experts available now in Live!

Get 1:1 Help Now