dividing one variable and store it into another variables

This is a discussion on "dividing one variable and store it into another variables" within the PHP Forum section. This forum, and the thread "dividing one variable and store it into another variables are both part of the Program Your Website category.



Go Back   Webforumz.com > Main Forums > Program Your Website > PHP Forum

Notices


Reply
 
LinkBack Thread Tools
  #1 (permalink)  
Old Dec 3rd, 2005, 08:10
Junior Member
Join Date: Dec 2005
Age: 29
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
dividing one variable and store it into another variables

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
Reply With Quote

  #2 (permalink)  
Old Dec 3rd, 2005, 11:02
Reputable Member
Join Date: Sep 2005
Location: Canada, BC
Age: 24
Posts: 239
Thanks: 0
Thanked 0 Times in 0 Posts
Re: dividing one variable and store it into another variables

take a look at http://ca.php.net/manual/en/function.preg-split.php
that function is probaly going to be the main part of it, working the specific details is to much for me at this hour, but good luck
Reply With Quote
  #3 (permalink)  
Old Dec 6th, 2005, 04:34
Junior Member
Join Date: Dec 2005
Age: 29
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
Re: dividing one variable and store it into another variables

hi,

i'm able to seperate the one variable and stores it into the three variable but in the following case what should i do??
i'm having one variable i.e.

$content="Jet+Airways%2CIndia%2C+Model%3A+Airbus%2 C+Departure%3A+13%2F02%2Fp.m.";

In the above variable the company name is also seperated by comma and other things i.e. Model and Departure are also seperated by comma.
and my expected result is as below:

$company="Jet Airways, India";
$model="Airbus";
$departure="13.02p.m.";

so in this case what shall i do?? where the seperator is comma.
Reply With Quote
  #4 (permalink)  
Old Dec 6th, 2005, 08:24
Rob's Avatar
Rob Rob is offline
Head Admin & CEO

SuperMember
Join Date: Jul 2003
Location: at my desk
Age: 34
Posts: 2,952
Blog Entries: 7
Thanks: 7
Thanked 4 Times in 4 Posts
Send a message via MSN to Rob Send a message via Skype™ to Rob
Re: dividing one variable and store it into another variables

If it's comma seperated, just split each element into an array, then just merge the specific array elements into one...

ie, merge (0) and (1) :- company
.... and the same for the other items.
__________________
Rob - SEO Specialist
Owner & Founder of Webforumz.com

I am currently unavailable for private work
Reply With Quote
  #5 (permalink)  
Old Dec 6th, 2005, 09:55
Junior Member
Join Date: Dec 2005
Age: 29
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
Re: dividing one variable and store it into another variables

hi rob,

thanx for the advice

but in this case there are some comapny names are seperated by comma
for example:

$item1="Air+Pacific%2C+Model%3A+Airbus%2C+Depart ure%3A+13%2F02%2Fp.m."&$item2="Jet+Airways%2CIndia %2C+Model%3A+Airbus%2 C+Departure%3A+13%2F02%2Fp.m"

in the above case in the first item the company name is not seperated by comma but in the second item the comapny name is seperated by comma and i want to use the dynamic script for that so that it will classify all the company's names no matter whereever the comma is.
Reply With Quote
  #6 (permalink)  
Old Dec 6th, 2005, 11:59
Rob's Avatar
Rob Rob is offline
Head Admin & CEO

SuperMember
Join Date: Jul 2003
Location: at my desk
Age: 34
Posts: 2,952
Blog Entries: 7
Thanks: 7
Thanked 4 Times in 4 Posts
Send a message via MSN to Rob Send a message via Skype™ to Rob
Re: dividing one variable and store it into another variables

Well.... if your data is has no integrity of consistant format, the only way you are going to do this is to bodge it.
You need to compile a list of company names that have a comma and cross-check with that list.

If you have no consitency in the data, I would be moaning like hell to the data provider to get some consistency and integrity in there.
__________________
Rob - SEO Specialist
Owner & Founder of Webforumz.com

I am currently unavailable for private work
Reply With Quote
Reply

Tags
dividing, variable, store, variables

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Content Placement + Content Dividing josephman1988 Website Planning 2 Jan 22nd, 2008 05:02
Add Store to my Website SawkaWorld Scripts and Online Services 3 Aug 16th, 2007 02:11
Designing an EBAY store Moonlilly Web Page Design 2 Mar 11th, 2007 10:25
how to store cookies selphie08 Flash & Multimedia Forum 3 Sep 20th, 2006 01:54
Dividing lines? joel Databases 0 Nov 3rd, 2005 19:46


All times are GMT. The time now is 18:32.


Powered by vBulletin®
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC8
© 2003-2008 Webforumz.com : All Rights Reserved

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43