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 - 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 Complete Forum Thread with Replies

Related Forum Messages:
Open A File To Store Some Date :: Permissions Dilemma
I want to open a file to store some data. However, when I use fopen('filename', w) I get permission denied. So, I've changed the permissions of the directory to get rid of the permission denied problem. Unfortunately, this seemed to require changing the directory to have permissions 777.

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 !
Explode Question - Query The Database With The Numbers
I have a string sored in my database like this 2,1|2,5|3,6 I have exploded this to get the following:

2,1
2,5
3,6

I now need to explode this again and as I need to query the database with the numbers. For example: Code:

View Replies !
Open A Text File And Put Into Array
I want to open the text file and put it into an array so i can search the contents of the text file.I've figured out how to search an array but cant seem to open a file into an array and then search it. I want to take blah.txt open it insert it into $some array
and then use the array_search function to search for the word the user puts into a form.If you can point me to a tutorial, that would be helpfull.This whole search thing is driving me nuts.Opening and writing to files is easy...now searching the files im writing to ??I'm lost.

View Replies !
Best Way To Store Phone Numbers
I would like to store prone number in db which may have the following fields:

(555) 555-5555 Ext. 5555

Now, the form that I have splits the input into 4 distinct groups to make it clear to user what to put in. There are a number of way it could be stored properly. For example I can just combile the values into one var and tuck it away, like: Code:

View Replies !
Attach Multiple Numbers And Store In Db
i have a simple form consisting of name, tel_no, mob_no, sales, flag which gets sent and stored in a mysql database and an email get sent as well.

however each customer could have upto 100 telephone numbers is there any way of allowing a user to add upto 100 telephone numbers for one customer and also store each different telephone number as a new record in the database?

View Replies !
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 !
Explode And Array
how to explode using for example:

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

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 !
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 !
Pass A Function As Array(&$sess_handler, 'open') Instead Of '$sess_handler->open'
In the function session_set_save_handler I can pass the name of function which deal with session. In Xoops code I see the use of this function like that: Code:

View Replies !
Explode To Get File Type
I'm pretty baffled at this. I'm not entirely sure why this isn't working:

$filetype= $_POST['file']['type']; // getting the file type
$file  = explode('.', $filetype); // exploding the string to return just the file type
$filename        = rand() . '.' . $file[1]; // renaming it and then adding the file type back to save the file

I'm trying to retrieve the file type seperately and then rename it.

View Replies !
Store Values In An Array
$a=10;
$a=15;

while ($a <= $b)
{
$a++;
}

The output is 10,11,12,13,14,15

How to store the values of $a(10,11,12,13,14,15) in an sigle array.

View Replies !
Store Classes In An Array?
Is it possible to store classes in an array? I am fairly new to PHP,
and haven't found anything either way yet.
I have a program that where you can have multiple notes attached to a
ticket, which are stored in a database. I would like to just pull all
the notes from the database, storing each one in a seperate class,
which itself is stored in an array (well, another class, but it's a
classList, it's mainly an array).
I'm getting an error when I run the page:
"Cannot use a scalar value as an array", and "Call to a member function
on a non-object". The second is related to the first, as I'm calling a
function on the array value.
If it is possible, I probably coded something wrong. If that's the
case, I'll post some code.

View Replies !
Get Data From The Db And Store It In An Array
I want to have an input field in my Admin CP when you are creating a Forum where you can input a list of numbers (member ids) seperated by commars, like this:

Quote1,6,4,8,2
These will be the ids of people who can moderate the Forum and will be stored in the db along with all the other stuff like forum name/description etc.

That's easy enough.

Now my problem is I need to get that from the db and store it in an array... basically so I can do something like:

<?php
if(in_array($_SESSION['mem_id'], $forum_moderator_array)) {
    echo('Congratulations, you are a forum moderator.');
}
?>

How can I go about doing this?

View Replies !
Store A Array As A Variable
is there any way that i can store a array as a variable because i dont want to creat a database for thousands of variables. heres what i thought of so far

<?PHP
$arrayval = "1,3,2,7,4,6,8,15,12,78,96,1203,1029,39509,12999";
$array = array($arrayval);
echo $array[1],$array[3],$array[2],$array[5],$array[6],$array[4],$array[7],$array[9],$array[5],$array[10],$array[13];
echo "<hr>";
echo $arrayval;
echo "<hr>";
$sum = $array[1]+$array[3]+$array[2]+$array[5]+$array[6]+$array[4]+$array[7]+$array[9]+$array[5]+$array[10]+$array[13];
echo $sum;
?>

View Replies !
Store Array In Session
i store my shopping carts items in an array in a session like this Code:

View Replies !
What's The Best Way To Store An Array In The Database
I am trying to build a simple tree menu where the main items can be either a link or open up a subList of items which themselves can belinks or open into more submenus and so on.
An example is:

$ar = array(
'new_user' => 'newuser.php',
'tst1' => array(
'subtst' => 'subtstlink.php',
'subtst2' => 'sublink2.php'
),
'heyhey' => 'heyhey.php',
);

I am wondering what is the best way to store that in a mysql database (Both the item name and the link to it). Is there any php function that will allow me to make such an array into some sort of variable (String?) which can then be read easilly and made back into the array for manipulation and creation of the tree menu?

View Replies !
How To Store Array In Cookies?
I try to store array in cookie this way:

for($i=0;$i<5;$i++)
{
    $field[]='test'.$i;
}
$_COOKIE['field2']=$field;

Is it possible do it that way? I don't want to store each value of array list store separately. I'd like to store them at once. If I was storing values just to another "normal" variable (not cookie), I would do it this way: Code:

View Replies !
How Do You Store An Sql Result In A Php Array?
How do you store an sql result in a php array? The array will hold, the following fields; itemid, itemname and itemdesc. I would then require, depending on the user selection to query the array by itmeid, and return the itemname.

View Replies !
Can I Store An Array In MySQL?
I would like to store an array in a MySQL table. The values will be numeric and ranging from 1-999. I'm not sure if this is possible, and if it is then I'm not sure on the correct field type to use.

View Replies !
Store Variable In An Array
so i have a query that returns a bunch of rows.... i display the contents of the query into a table... one of the variables that the query returns is $title....

after each row is returned im wanting to store the $title variable into an array, so i can then access that array later... here is my code for storing $title into the array Code:

View Replies !
Use Explode To Separate The Result Of A Textual File
I'm trying to use explode to separate the result of a textual file, but it explode me only the first row.

the foo.txt is
pippo pluto
pluto pippo
pippo pippo
....

I use this script found in http://it2.php.net/manual/en/function.explode.php

$pizza = "/var/www/foo.txt";
$pieces = explode(" ", $pizza);
echo $pieces[0]; // piece1
echo $pieces[1]; // piece2

View Replies !
Store An Array In A Text Document
I want to store an array in a text document. what I've been doing so far looks like this:

fputs( $myFile, $myArray );

but all it does is write the word "Array", instead of the actual array. I'm new to php and I've done my best to search the manual and numerous web resources (including this forum) for an answer, so please don't flame.

View Replies !
Store Mysql Results Into An Array
i just started using php. i've used it before as a maintainer. fun stuff. well now i'm the writer. i want to abstract all the DB commands away from myself and all other developers. so i'm writing a function to query the php database from all users of the database and store them into an array as a return value so that i can seperate my database code from my html creation code.

1. is there a way to put all my database functions into a php file and include that file into all my other php pages? similiarly to a #include in C++ or a import package name in Java?

2. my code to run down the fetched results and store them into an array doesn't seem to be working the way i want it to. if i print out the results from the mysql returned fetch the data is fine. however the array seems to print out "Array[elementnumber]" instead of the value. Code:

View Replies !
How To Store Checkbox Values To An Array?
I need to allow the user to select multiple mysql records via an html form checkbox.  On submission of the form I would like to store these values in an array for either multiple record deletion or creating a list of records. Code:

View Replies !
Four Fields That Are Dates, Store As An Array
I have a form that has over 100 fields. I have four fields that are dates that I would like to store as an array. When I submit the form I place the dates in the array like so:

$planworkdate = array("mon" => $planworkdate0,"tue" =>$planworkdate1,"wed" =>$planworkdate2,"thu" =>$planworkdate3);

and insert into mysql database. When I try to retrieve the data I get the word Array for the result. What am I doing wrong?

$query = "SELECT planworkdate from general";
$resultall = mysql_query($query);
$planworkdate=mysql_result($resultall,$x,"planworkdate");

print $planworkdate; ...

View Replies !
Take All The Results From A Query And Store Them In An Array
trying to get my head around arrays, and I want to take all the results from a query and store them in an array so that I can use them  for later use: Code:

View Replies !
Store Form Fields To An Array
i have a form which consists of several fields for name, address, number etc. i use a php form to process this and output it onto a html form. the thing is, i'd like to store the information in an array. so for each user, the array will have their details. and this can be printed on the screen. can you tell me how this is possible. i have seen examples of arrays, but the values are assigned to the variables already.

View Replies !
Store The Entire Table In A Two Dimensional Array
I am reading info from a tab-delimited text file and I was wondering if anyone knew how to get this concept to work. I am trying to store the entire table in a two dimensional array, but the way I'm doing it right now won't work.

for($i=0; $i<$numrows; $i++)
{$columnsvalue[i] = explode(" ",$newfile[i]);}

does anyone else know how to better work with multi-dimensional arrays?

View Replies !
Mysql_fetch_array Way To Pull Out All The Data, Store It In An Array
I have a webpage which runs repetitive queries agaist a database in order to extract one item at a time and then put the items in an HTML table. The reason for this is formatting, plus the page hits 4 databases.

Instead of running multiple queries pulling one item at a time...is there a way to pull out all the data, store it in an array, and then pull individual items from the array with php as I want to insert them in the table? So, example is Code:

View Replies !
Variables To Store (Name,Species,Sex) Inside An Array
In PHP, is there anyway of using variables to store each piece of information (Name,Species,Sex) inside an array. Then, when it comes to fetching the information, the array position (e.g. 0) is called along with the information type (Name etc). A bit like the following: record(1).name The information is coming from the record array, at position 1 displaying names.

View Replies !
Login Script: Parsing Flat File Using List() And Explode()
how to use php and am trying to solve a problem with this part of my login script for checking a text file of members to see if the user name and password they entered into a login page exists and matches one of the records in a flat text file database. Code:

View Replies !
Store While Statment Data In Array Using Session And Retrieve?
I wish to store retreve value from my sql using session array and retrieve this value.
here is my while statement, which is displaying records from my database. I want to store all this value in an array using session and than retrieve this value on click of the table row. Code:

View Replies !
Array Problem - Extract And Store In Seprate Variables .
I have an array from a program of the type $list_box_contents[$row][$col]['text'];
 There are 3 columns  and an indefinite no. of rows.

Each array element contains a few bits of information. I want to to extract this and store in seprate variables .

$list_box_contents[$row][2]['text']; has 2 bits of information, a price and a small text box with some text. How can extract the price data from this .

View Replies !
Store The Selected Checkbox Values In A Variable Or An Array?
how to store the selected checkbox values in a variable or an array?

View Replies !
Array Problem... - Store This List In $_SESSION['liste'];
the user selects 6 numbers in a list I have to store this list in $_SESSION['liste']; (I cant do it differently) the list is stored like that: 34-21-44-32-12-11 (cant do it differently either)

what I need to do is to explode the array, get rid of the - , sort the values in ascending order and send them to my table as a string. so in the end I should have: 111221323444

I tried using a variation of laserlight's script (given in a previous post) without success... hope that someone will have time to give me a hand again in telling me what I could change in saberlights script to make it work.

View Replies !
Counting Numbers In Array
Assume I have an array which contains the following numbers:
2
5
7
9

How would I go about adding them to eachother?( e.g. in this case 2+5+7+9 would be 23)

View Replies !
Read Numbers Into An Array
i've got numbers written in file like that:

0.005465
0.004564
....

I want to read them into an array and have the same effect like:
$arr=array(0.005465,0.004564,..)

Do you know how to o it?

i tried something like that:

$file_name = "file_name";
$fp=fopen($file_name,"r");
$arr=implode(' ',file($file_name));
$arr2=explode(' ',$arr);

and wanted that an arr2 to be my array..

but it has no result...

View Replies !

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