hi all,
i want to know whether it is possible to determine the particular character in the string??
i'm having one variable i.e.
$content="Air+Pacific%2C+Model%3A+Airbus%2C+Depart ure%3A+13%2F02%2Fp.m.";
i want to divide the above variable into three different variables so the result i'm expecting is :
$company="Air Pacific";
$model="Airbus";
$departure="13.02p.m.";
so is it possible in php??
anybody is having any idea??
thanx in advance
regards
amit
dividing one variable and store it into another variables
Moderator: General Moderators
-
amitshetye
- Forum Newbie
- Posts: 12
- Joined: Thu Dec 01, 2005 12:00 am
Next time, please put your code in [ php ] tags. Makes it a lot easier to read.
Try this:
Try this:
Code: Select all
$string = urldecode('Air+Pacific%2C+Model%3A+Airbus%2C+Depart ure%3A+13%2F02%2Fp.m.');
$parts = explode(', ', $string);
foreach ($parts as $i => $part) {
$split = explode(': ', $part);
$parts[$i] = $split[sizeof($split)-1];
}
list($company, $model, $departure) = $parts;
Last edited by foobar on Sat Dec 03, 2005 4:52 am, edited 2 times in total.
- shiznatix
- DevNet Master
- Posts: 2745
- Joined: Tue Dec 28, 2004 5:57 pm
- Location: Tallinn, Estonia
- Contact:
foobar wrote:Next time, please put your code inCode: Select all
tags. Makes it a lot easier to read.[/quote] also note that if you say "Code: Select all
" without having a closing tag it will not parse the rest of message if you use the php tags properly.
shiznatix wrote:foobar wrote:Next time, please put your code inCode: Select all
tags. Makes it a lot easier to read.[/quote] also note that if you say "Code: Select all
" without having a closing tag it will not parse the rest of message if you use the php tags properly. [/quote] I do have a closing tag. [edit] Oh, ok. I get it.