Editing values on a simple array

Posted on 2005-04-05
Last Modified: 2006-11-18
Hi everyone ;

This one is a annoying situation

I have a array, that gets feed from a web form.

like this :      "2+3+4/20"

it puts in the first element of the array

but i want it to be like this  : $a[0] = "2" , $a[1]="+".... $a[6]="20"

Now, note that the last elemet is a two digit number, so if you use this command :
$kstring = preg_split("//", $input);

it will take as a "2" and "0"

you have to find  a way arround this ...

Goodluck guys, and thanks alot!!!!

Question by:cemaykan

    Author Comment


    the only operands used are (*, +, /,-) ... The rest are integer numbers...

    LVL 33

    Accepted Solution

    $a = preg_split("|([-+*/])|", $input, -1, PREG_SPLIT_DELIM_CAPTURE)
    LVL 14

    Expert Comment

    No comment has been added to this question in more than 21 days, so it is now classified as abandoned..
    I will leave the following recommendation for this question in the Cleanup topic area:
    Accept: snoyes_jw {http:#13711559}

    Any objections should be posted here in the next 4 days. After that time, the question will be closed.

    EE Cleanup Volunteer

    Featured Post

    Why You Should Analyze Threat Actor TTPs

    After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

    Join & Write a Comment

    Suggested Solutions

    Deprecated and Headed for the Dustbin By now, you have probably heard that some PHP features, while convenient, can also cause PHP security problems.  This article discusses one of those, called register_globals.  It is a thing you do not want.  …
    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…
    This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
    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 …

    729 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

    23 Experts available now in Live!

    Get 1:1 Help Now