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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
change password links 7 72
Keep getting 503 on Curl request 6 30
How do I execute a file from within a PHP script with headers already sent? 5 20
html input type 3 21
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…
Part of the Global Positioning System A geocode ( is the major subset of a GPS coordinate (, the other parts being the altitude and t…
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

911 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

20 Experts available now in Live!

Get 1:1 Help Now