Editing values on a simple array

Posted on 2005-04-05
Medium Priority
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

ID: 13711485

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

LVL 33

Accepted Solution

snoyes_jw earned 1000 total points
ID: 13711559
$a = preg_split("|([-+*/])|", $input, -1, PREG_SPLIT_DELIM_CAPTURE)
LVL 14

Expert Comment

ID: 15983491
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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

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…
Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
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.
Suggested Courses
Course of the Month15 days, 3 hours left to enroll

840 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