Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
  Advanced Search
  HOME    TRACKER    PHP


SuperbHosting.net have generously sponsored dedicated servers to ensure a reliable and scalable dedicated hosting solution for BigResource.com.





Explode And Array


how to explode using for example:

$domain_handle= explode("", $rec_handle);




View Complete Forum Thread with Replies

Related Forum Messages:
Array Explode Problem Result In A 6 Item Array
I have the following:

$BB_Basket = "basket=¦APL6007,2.00¦AVX8900,1.00¦ARCAV500,1.00";
$basket_containers = explode('¦', $BB_Basket);
unset($basket_containers[0]);
print_r($basket_containers);

This results in

Array ( [1] => APL6007,2.00 [2] => AVX8900,1.00 [3] => ARCAV500,1.00 )

Now when I try to explode further with

$basket_items = explode(',', $basket_containers);
print_r($basket_items);

This results in

Array ( [0] => Array )

This should result in a 6 item array. Any ideas what I'm doing wrong?

View Replies !
Explode Array Created An Automatic Key For Each Row In The Array.
I have a string, like this:

Userid1 Pass1
Userid2 Pass2
Userid3 Pass3
Userid4 Pass4

Each column is tab separated. I want to explode it into an array so that the userid will be the key, and the password the value. I tried to do it like this:

$array = explode(" ", $string); // Where $string is the string above.

However, this returned both the userid and the password as the value, and created an automatic key for each row in the array.

View Replies !
Explode Array
I have an array name, text=value, text=value, name, text=value, name,.... and I want to do something like:

for($n = 0; $n < count($a), $n++){ //where $a is the array
$b = explode ("=",$a[n]);
}

So that I get a new array $b looking like name,text,value, text,value.

View Replies !
Explode Into An Array?
I'm trying to do: explode some data into another array. I will have the code in a loop so that the data in all elements of $RowData gets split up.

I would like $ZoneCodes[0] to contain 4 elements, but I would like them to be in the next dimension. i.e. [0][0], [0][1],[0][2],[0][3] Code:

View Replies !
Explode My Array
i have a loop which stores the values in the array $store...i am using the following script after storing the values in $store now if $store[0 or whatever]="john doe" i want the $link as "john_doe" i tried ereg_replace but that also dont seem to work..so please guide in either cases Code:

View Replies !
Using Explode, On An Array?
Our website has a spanish and english version, the data for both languages are pulled using an arrays of arrays. I have one file that contains all of the arrays, here is an example of one

$products = array{
"dirtbike"=>array("dirtbike_eng","dirtbike_sp"),
}
A session variable is set (0 for English, 1 for Spanish) and the appropiate translation is pulled out of the array based on that.

It works great, easy to update and change things on our site...but now we want to take the task of translating and updating the page out of the hands of our web designer (me) and let operations do it.  They want a simple text file that they can edit and just upload to the web server for the changes to take effect...here is an example of what I have given them (translation.txt)

ID ------ English ----- Spanish
dirtbike | dirtbike_eng | dirtbike_sp

I can read the translation.txt file fine using $data=file(translation.txt);
Now it puts each line into an array.   What I want to do, is use explode on each line (using a ' | ' delimiter) and output each line into it's own array of arrays. Code:

View Replies !
How To Explode Array From File?
contents of myfile.txt = 5035|9638742|11938 // (one line of text)

$myfile = "/home/path/public_html/myfile.txt";
$totals = file($myfile);
$var = explode("|", $totals[0]);
$i = number_format($var[0]);
$k = number_format($var[1]);

For some reason this is acting funny. I am getting a null value for $k for some
reason...

Is there a better way to do this?

View Replies !
Array Explode Problem
I have the following: Code:

$fontfind .= &#3915;,'
$fontfind .= &#3925;,'
$fontfind .= &#3935;,'

$found = explode(",", $fontfind);


When I do:


Code:
print_r(explode(",",$fontfind));


It prints
Array ( [0] => 15 [1] => 25 [2] => 35)

but
print $found[0];

It prints
1

What's going on?

View Replies !
Explode Into Array Question
I have a 4 character string which can be any 4 characters in any position within the string itself and I want to explode it into an array.

Normally I would explode it using a delimeter such as a comma or a space but how do I do it when there is no delimeter??

View Replies !
Explode Array Counting?
I am trying to count the number of pieces of an explode so that I can run a foreach command. My code goes out and grabs work order codes from the database.

Then runs and explode command to separate those codes. But I have to count how many codes there are to be able to run a foreach. Any ideas? Code:

View Replies !
How To Get The Number Of Values In An Array After I Use Explode
I have the following variable which has three areacodes in it:

$areacode = "305,954,786"

$array = explode(",", $areacode);

after i explode $areacode, How to get the info. how many areacodes are there in($areacode). in the above example it is 3 area codes (305, 954, 786)

$array[0] equals 305
$array[1] equals 954
$array[2] equals 786

View Replies !
Changing Array Keys After Using Explode
I have used explode to split a string into parts but the the resulting array keys are ints...is there a simple way of changing the keys from numbers to informative values?

View Replies !
Explode Array The Userid Will Be The Key, And The Password The Value
I have a string, like this:

Userid1 Pass1
Userid2 Pass2
Userid3 Pass3
Userid4 Pass4

Each column is tab separated. I want to explode it into an array so that the userid will be the key, and the password the value. I tried to do it like this:

$array = explode(" ", $string); // Where $string is the string above.

View Replies !
Smarty - 'explode' String Into An Array Or 2 Variables
I've a smarty var, like this:
{$var}
that is equal to: ttttttttttttt|zzzzzzzzzzzz

It can be any size, the important is that they are separated by the '|'

How do I 'explode' that into an array or 2 variables in the smarty template
?

So I can just use:
{$var[0]} = ttttttttttttt;
{$var[0]} = zzzzzzzzzzzz;

View Replies !
Explode Text Area Into Array For MySQL Table
On my site, I have a textarea where users enter their sites' information in the following format (tab-delimited):

Site Name <tab> Site Description <tab> URL <newline>
Site Name <tab> Site Description <tab> URL <newline>
(and so on...)

I know I have to use the "Explode function and a loop to get the data into an array and enter it into a MySQL table. Would anyone have a snippet of code off-hand that could show me how to do this?

View Replies !
Explode Function To Split Up A String And Turn It Into An Array
I'm using PHP explode function to split up a string and turn it into an array. All works fine except the array keys are automatically started at [0] then [1] etc. etc. How can I explode the string and have my array keys starting at [A] then [b] then [C] etc.. etc..?

View Replies !
Explode - Open File Store The Numbers In An Array
I have a .txt file looking like this

3
4
56
23
59
10

i want PHP to open that file and store the numbers in an array something like this

$q = "3,4,56,59,10"

Now i want to read $q and see if it contains 56 and 10 (it does) Code:

View Replies !
Create A Comma Delimited String That I Can Convert To An Array Using Explode();.
I am attempting to create a comma delimited string that I can convert to an array using explode();. I have the following code: Code:

$cPath_new_a = tep_get_path($categories['categories_id']);
$cPath_new_b = str_replace("cPath=", "", "$cPath_new_a");
$cPath_new_c = str_replace("_", "", "$cPath_new_b");
$cPath_new_d = substr("$cPath_new_c", -2, 2);

$cPath_new_e = $cPath_new_d . ",";

echo $cPath_new_e;


This outputs 23,53,

I need it to output 23,53 Using the substr($cPath_new_e, 0, -1); and/or rtrim() method to remove the last character for some reason removes all of the commas. Am I approaching this the right way?

View Replies !
Explode()
Why won't this script work. The values in the database are:
http://localhost/file.php, http://localhost/file.htm
Any ideas to where i am going wrong?

View Replies !
Explode?
I've just had anti virus installed on my server. There is a log file that shows all the viruses that have been trapped. There are lots of different lines in the log file but the ones I'm interested in look like this:

/var/amavis/amavis-012184/parts/part-00002: Worm.SomeFool.B-petite FOUND

What I want to write a little PHP script that will display the results on a web page. So, my first task will be to extract only the lines that begine with /var/amavis, or even only those that end with FOUND.

Then I want to take all the characters between the : and the F and display those.

It would be nice if I could display a count of how many viruses had been caught so far.

Lastly, I really only want to display, say, 30 lines at a time.

Then I pop a refresh on the page and we can hopefully see the viruses as they come in. It's just so I can show customers how clever this is.

I'm going to start digging myself through the PHP manual but if anyone could offer any guidance I'd be most grateful. I think it might be explode that I want to use, but I'm not sure. Nor am I sure how to select only the relevant lines and just display the last 30.

View Replies !
PHP Explode()
I am planning on writing a "customer ordering system" and in an effort to conserve database space, I was thinking of setting the "ordered" item_id's into a single column, comma separated.

Now, the explode() function gives me a method of "separating" data (in this case) by the comma. Naturally this would give me an "Array" to loop through and so on. Is this the right idea?

View Replies !
Explode Twice
I have a sql row with this information:

11/12/07.10am.vs Lions|11/13/07.9am.vs Sharks|11/15/07.9am.Practice|11/16/07.10am.Practice|11/18/07.11am.vs Frogs|

I need to explode the events and then explode the sections. So, basically I need to explode the | which separates the events. Then I need to explode . that separates each item in the event.

How would this look? I have tried different things exploding and foreach and just haven't gotten it to work yet. The above basically needs to create a tables of events...

View Replies !
Explode To <ul><li>
I want to explode a string:

$string = "one, two, three"

As an example, into something like this:
<ul><li>one</li><li>two</li><li>three</li></ul>

I've looked around google, but I know you guys are pretty good. Any ideas?

View Replies !
Using Explode
I have a table called "fanlistings"

I then have fields
FanlistingID
FanlistingName etc.
SpecialFieldName
SpecialFieldOptions

The two I am concentrating on are SpecialFieldName and SpecialFieldOptions. SpecialFieldName is what the drop down box will be called. i.e. HTML Code:
<select name="<?=$Settings[SpecialFieldName];?>">


OK an example of the data in the two fields would be:
SpecialFieldName = grapes_type
SpecialFieldOptions = White,Purple,Both

What I need to do, using explode is to then turn each SpecialFieldOption seperated by a "," into an option in the drop down box.

View Replies !
Explode
On my form I have checkboxes, where they chose what kind of pop they drink, alot of them such as : PHP Code:

<input type="checkbox" name="pop[]" value="Coke"> Coke<br>
<input type="checkbox" name="pop[]" value="7up"> 7up<br>

Now I imploded them into database with a space and looks like this in table: PHP Code:

*Coke*7up*

Now I know I need to explode it to show what has been checked...uch as : Code:

View Replies !
Trying To Use Explode
I have a row in my mysql table called member_of_ladder. in that row is data formatted like so Night lance; cool; test1; test2; now what I'm looking to do is drop the ; and put the values into a drop down menue. Code:

View Replies !
Way To Explode A Space
I would like to know if there is a way to
explode a space no matter what it is.

View Replies !
Split/explode - There Must Be A Way!!
I have a text string, say $text = "abcdefg" and I want to split/explode it up so that each individual character is stored in an array.

I've tryed explode, but it wants a delimiter - any ideas?

View Replies !
Explode() Question
If i have the following code:

View Replies !
Question About Explode()
How would I make a variable from the last piece from an explode() function?

I'm having to deal with filenames that have different amounts of "." in them.

Some are normal, such as filename.jpg

Yet some have more dots, such as "file.photo.1.jpg"

So how would I get a variable from the last piece, which is the actual extention?

Bear in mind that not all extentions I'm dealing with have three letters, some are JPG, some are JPEG, so a simple strstr() will now work.

View Replies !
Help With Explode Function
Ok, now I have been working on this for at least a week and I can't figure it out. This is code taken from a news script called Zaimlog where it was originally set up to have each entry stored in a seperate file where the date, time, and entry where stored on seperate lines, but I want to change it so that the date, time, and entry are seperated by "|". I have been working with the explode function and have read stuff on php.net but I really need help here is the code:

View Replies !
Explode-ing QUERY_STRING
I'm trying to write a script that will take the inputs from two fields (region and specialties - view here)and return all rows in a MySQL table that match ANY region and/or ALL specialties selected.

I explained in another help setting that my when I submitted a search with, for example, two regions, and the query string looked like "search.php?location=Toronto&location=KW&submit=Search", when I echoed the value of the query string I got only "KW". They said I can't pass two variables of the same name in one query string, since all but the last will be overwritten. They also told me I had to parse the query string manually.

Now, I've been looking at the PHP manual for just how to do this, and I haven't gotten any farther. I think I need to use the $explode function, but I can't figure out how to use that to get separate variable names for all the regions and/or specialties inputted, or how to change the search function I already have.

The PHP I'm currently working with is here.

View Replies !
Var String Explode?
I exploded a url string into an array like so:

type=eating
numrec=2
drink0=milk
fruit0=apple
dessert0=icecream
adate0=05/02/2002
drink1=beer
fruit1=peach
dessert1=chocolate
adate1=06/02/2002

Note that the variables end with a digit, starting from zero. The first two vars tell what type of posting it is, and how many posts there are. Here we have 2. What I want to do is to make insert statements for MySQL for each variable.

Example: insert into mytable (drink, fruit, dessert, adate) values ("milk", "apple", "icecream', now());

And then another insert -
insert into mytable (drink, fruit, dessert, adate) values ("beer", "peach", "chocolate", now());

Any ideas how I can take these vars I exploded and get rid of the digits at the end and make them into insert statements?

View Replies !
Explode, Split, Or Something Else
I have a string that looks something like: <some stuff><some more stuff><etc>. I want to seperate the information based on ">", but by using explode and split it gets rid of ">". I don't want that to happen. Is there a built in function that I am overlooking that will do this?

View Replies !
Implode <-> Explode
I'm able to figure out how implode() works. Now, my question is: is explode() the opposite of implode()? because, I've written a little test code: you have a select box and you can select multiple options.

I implode these options and I put these in a database (I have too, won't explain it, it's quite hard hehe) so I get somehing like these in my database: option1|option2|option now, i want too extract these variables and put them again in a new select box, and I have to remove those '|', and I think it must be possible with explode() or split(), I'm not sure, I've tried a lot, rtfm', but it didn't work so fare, anyone an idea ? Code:

View Replies !
Explode And Memory
When using explode on a string, you split it up into an array right? Does that array stay in the RAM, or in some weird browser memory/cache? And either way, do I have to empty that memory myself?

View Replies !
Explode Doesn't Seem To Work
$ttt = array();
$ttt = explode("-", "test-niet");
echo "$ttt[0] | $ttt[1]<br>";

Should give
test | niet

but gives

test-niet |

Which meens the string is cut into 2 pieces. Someone knows what i m doing
wrong?

View Replies !
Query On Explode()
Have a look at the following code

$test = explode('-','one-two-three-four-five');
print_r($test);

Output:
Array
(
[0] =one
[1] =two
[2] =three
[3] =four
[4] =five
)

But What I need is

Array
(
[one] =one
[two] =two
[three] =three
[four] =four
[five] =five
)

View Replies !
List And Explode
I have been searching for a reason for this behavior but no solution
so I figured I would ask.

Basically I have a web page that displays data in a database to the
user for updates/deletion/addition. For each data field ont he web
page I put the data from the database in the field name with teh field
name and data seperated by a |. ex: address|35 Elm St.

I then loop thru all the fields on the form and if the data in the
field name doesnt match the data submitted then update the database.
Here is the code:

foreach ($_REQUEST as $curFld => $Data) {
if ($curFld <> 'Submit') {
list ($field, $orig_data, $table, $id) = explode('|', $curFld);

if ($orig_data <> $_POST[$curFld]) {
//UPDATE DATABASE
$sql = "UPDATE $table SET $field = '".$_POST[$curFld]."' WHERE
ID = $id";
$result = mysql_query($sql, $_SESSION['conn']) or
die(mysql_error());
}
}
}

Here is the problem, either list() or explode() is replacing all
spaces in $orig_data with underscores so 35 Elm St. becomes
35_Elm_St.. This causes the code to always update this field and any
others where this occurs. Obviously I could do this str_replace("_",
" ", $orig)data) to fix this problem but if the user wants to use
underscores I dont want to replace them. (Address is not the only
field on the page.



View Replies !
Explode String
how do you explode string with two conditions, space and newline?

i use strtok but i could only use 1 condition
i cannot use the 2 condition space and newline

i want to explode a string with if a string has a space and newline?
how do i do that?

View Replies !
PHP Explode -> All Characters Before The First Dot
I basically need to remove all characters of a string before the first dot for an example:

I have a phrase: statistics.STATUS   

this should be the result:   STATUS

this is a post var dinamically loaded, so i don't know if to use str_replace or there is another function that i can call.

View Replies !
Explode Site Name
i have a web site name called www.welcome.com. i want to break or explode the site name and store in 3 different variables as follows:

$variable1=www;
$variable2=welcome;
$variable3=com;

how i can achieve this?

View Replies !
Explode Integers
If I have the below string how can I only explode only the interger values into an array?
$string="1,2,hi,453,222,bye,,,32,";

View Replies !
Explode Text
Im using explode to read the first line of a txt file (this lines contains the headers), and i get the array with all fields indexed in an array. while searching the result array, everything mtches except for the last field.

field1 field2 field3 field4 field5
xx cc vv bb nn

$fileHeader = explode(" ", fgets($fileOpen));

ill get an array
[0] = "xx"
[1] = "cc"
[2] = "vv"
[3] = "bb"
[4] = "nn"

if i use in_array("xx", $fileHeader ) its found
if i use in_array("nn", $fileHeader ) its NOT found

i thought it might be of line break. but still not working.

View Replies !
Explode Function
I am trying to separate this: mydomainmyname

To do this I am using the explode function as such:

$word = "mydomainmyname";
$separated = explode("", $word);

echo $separated[0];
echo $separated[1];

However, the backslash does not work. Is there a way to explode backslashes?

View Replies !
Explode URL And Use Script
I have a script that I made that lets a user type in their username & country and then generates a signature image (PNG) for them to put as their signature in a forum.

Right now, they can go to:

http://mysitehere.com/sig.html

Type in Username, Country, and select a signature background image.

Then it will go through a script: sig.php that builds the image based on their username, country, and selected background. Code:

View Replies !
Explode Command
I need an explode command to brake a directory struction into variables?

Example: /dir1/dir2/

I would like dir1 to be a variable as well as dir2 but have it not to display error messages if dir2 is missing and have it not to miss up when additonal /dir#/ or filename is added. If an explode command is what I need can you please post or if another way to do this is better than explain.

View Replies !
Explode Not Splitting
I'm trying to explode an string into an array:

<? $monetary_discount_to_update = implode(' ', $_POST['monetary_discount_']);
$monetary_array;
$monetary_array = explode(' ', $monetary_discount_to_update);

foreach ($monetary_array as $monetary_array_values){

echo($monetary_array_values[0]);

}

?>
But when I output the array in the foreach statement it only outputs the first character of each of the array values, and I want to output all of the array value. Have I made my array the wrong way or is the explode syntax.

View Replies !
Explode() Not Working
I'm trying to use the explode() function to import some data. I've tried both csv and tab delimited with the same result. It leaves fields out for what seems like no reason.

For example, if the line is:

$line = "0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,"

the result leaves out 10 and 11. sometimes it's other fields but more often that not it's those 2 no matter what the data is.

View Replies !
Explode A String
We have a database that has a field called "response". This field contains a bunch of lines like this -

x_trans_id=1234567
x_response_code=true
x_idnum=7458393
x_amount=95.00

We need to extract each line from this field and place them into an array. More specifically we need to pull out the x_trans_id field. Sometimes there are many arameters listed, sometimes only a few are listed, ommitng the x_trans_id. I tried parse_str($string, $dataArray);, but that put everything under one key in the array. How do you go about "tokenizing" a string into an array delimited by lines?

View Replies !
Implode & Explode
explain me implode &amp; explode in dumb english slang. i've read the manual, and i dont register. i''ve tried echoing examples based on the manuel, and perhaps i'm not getting it.

View Replies !
Question On Explode
How can I tell the explode() function to accept multiple similar types of delimiters.

I want it break up the string on the following "," " ," " , " ", " Bascially I want it to be able to detect the comma reguardless of whitespace.

View Replies !

Copyright © 2005-08 www.BigResource.com, All rights reserved