Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7073127
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T05:53:31+00:00 2026-05-28T05:53:31+00:00

I am stuck with a small problem in PHP with string function. I’m fetching

  • 0

I am stuck with a small problem in PHP with string function. I’m fetching last row value from the emp_id column. This gives me 1mw112 and this is a correct result. What I want actually to increment it automatically which is not possible because of this
emp_id is mixed of characters and numbers. What I can try to do now is to split this
value into two parts ( 1mw and 112 ). If this is possible then I can store 112 in another variable and can easily increment by 1 manually and while inserting in to the table; I can display it in readonly format in a form. I’ve tried str_split($var,3), but is not working.

This is what m trying with:

<?php
    $db=mysql_connect("localhost","m","m");// database connection
    mysql_select_db("mars",$db); // database selection

    //$query1="SELECT LAST(eid) AS eid FROM emp_info" ;

    $query1="SELECT eid FROM emp_info ORDER BY eid DESC LIMIT 1"; // sql query to select last value from the column
    $result=mysql_query($query1);

    while($record=mysql_fetch_assoc($result))
    {
        while(each($record))
        {
            $eid=$record['eid'];
        }
    }

    echo $eid;
    echo "<br>";
    $splitted=str_split($eid,-2);
    echo $splitted;
?>

This is echoing “array” as an output.

Can anyone please help me out to store last 3 digits in an another variable?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T05:53:32+00:00Added an answer on May 28, 2026 at 5:53 am

    $splitted is an array, which means you have to iterate through the array to get the values of it.

    In your case, you could do this, instead::

    $splitted = str_split($eid, 3);
    $splitted[1]++;
    
    $eid = implode("", $splitted);
    echo $eid;
    

    This will enable you to get the result you wan’t as long as eid follows the same format.

    UPDATE
    To answer the question that came in the comment, another solution could be this:

    $eid = "1mv112";
    
    $splitted = explode("mv", $eid);
    $splitted[1]++;
    
    $eid = implode("mv", $splitted);
    echo $eid;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i am stuck with this small problem in my code. I am trying to
I am stuck with a small problem here.. What i am trying to do
I have some small problem in understanding Value Objects in Flex... I'm trying to
I have a small problem here which I really am quite stuck in right
So I've been stuck on this problem for a day or so now and
I am currently stuck on a small problem. I have a List View which
I've got a little stuck with a small problem here: I use serialport communications
I'm stuck on a small but tricky problem since yesterday. What I have is
Recently I was trying to solve a small AI problem but got stuck in
I am stuck with a following problem: built a small application in asp.net, which

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.