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.





Changing An Array Name.


If I have an array called my_array1, how do I call it within a for cycle? Something like this:

for($a=1;$a<=5;++$a){
$my_array = 'my_array'.$a;
          //prints $my_array
}

I know that doesnt work, so, I tried something like the following:

for($a=1;$a<=5;++$a){
$my_array = 'my_array'.$a;
          //prints $$my_array
}

That does work with variables, but doesnt work with arrays. I know that in Java and ActionScript what I'm trying to acomplish is pretty simple, but I cant seem to find the correct syntax for php.




View Complete Forum Thread with Replies

Related Forum Messages:
Changing Array Keys
I've looked and looked and apparently I don't know what terms I'm supposed to be looking for. Code:

View Replies !
Changing A Value Of An Element In A Two Dimensional Array
I am having a problem with array manipulation.

in my php script i am reading from a csv file.
the content of file is like this:

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 !
Changing Object Data In An Array Of Objects
In this sample script I create an array of objects. Print out their data
with print_r().Update their data with a sub called v_set(). Print out data
showing the chnages using print_r(). I push the altered objects into a new
array and print them out again, still see the updated data. Then I iterate
over the original array again with print_r and the objects lose the updates
and have their original data.

<?
for ($i = 0; $i < 1; $i++) {
$listingObj = new Listing;
$listings[] = $listingObj;
}

foreach ($listings as $aListing) {
echo "<h3>THIS IS IN SCRIPT IN ORIG ARRAY BEFORE VARS SET</h3>";
f_array($aListing);
}

foreach ($listings as $aListing) {
$aListing->v_set(
array(
'name' => 'Jane',
'address' => Ïã Ohce Ln.'
)
);
// HERE IS BUG: WHY DO I NEED TO PUT IN NEW ARRAY?
echo "<h3>THIS IS IN SCRIPT IN ORIG ARRAY AFTER VARS SET</h3>";
f_array($aListing);
$newArray[] = $aListing;
}

foreach ($newArray as $aListing) {
echo "<h3>THIS IS IN NEW ARRAY</h3>";
f_array($aListing);
}

foreach ($listings as $aListing) {
echo "<h3>THIS IS IN ORIG ARRAY, APPARENTLY NOT
ALTERED/UPDATED?</h3>";
f_array($aListing);
}

class Listing {
var $changedVals = array();
var $name = 'Dick'
var $address = ì« Echo Ln.'

function v_set($data){
foreach ($data as $key => $value) {
$this->$key = $value;
$this->changedVals[] = $key;
}
}
}

function f_array($array) {
echo '<pre>'
print_r($array);
echo '</pre>'
}

?>

View Replies !
Changing Array Format From Result Of MySQL
here is what MySQL returns in a visual way..

game_id | team_id | stat_id
1 | 1 | 1
1 | 2 | 3
1 | 3 | 7
1 | 3 | 6
2 | 1 | 1
2 | 4 | 3

in records with the same game_id, there will be no repeating team_id
in records with the same team_id, there will be no repeating stat_id

so, after I got the query, I made them into this format

PHP Code:

View Replies !
Changing Php.ini
is there a way to change values in php.ini (like adding support for certain things) if you are not hosting your site yourself, like using a pay host?

View Replies !
Changing Id With Php ?
I want to know if it's possible to take an included file and change some lines when echo-ing? Code:

View Replies !
Changing
I am looking for some help with changing this so that I can download a file as html instead of cvs. I am not a programmer so I really don't know but have good ability to follow instrctions.

<?
if(file_exists($filename))
{
$fp=fopen($filename,"r");
$content=fread($fp,filesize($filename));
fclose($fp);
header("Content-type:application/vnd.ms-csv");
header("Content-Disposition:filename=$filename");
echo $content;
}
?>

View Replies !
Changing 'The Name' To 'Name
So I have a list, listed alphabetically:

Attic
Fish
The Bear

That I want to list like this:

Attic
Bear, The
Fish


Is there an easy way of doing this in a mysql query? or would I have to put all results in an array first,changing the results with 'The' at the start, and then read the results out again alphabetically?

View Replies !
Changing...
Does anybody know how to change the content in the navigation bar by any chance?

View Replies !
Changing Passwords
I'm using proftpd with mysql, it's working great. I creaded a site that a proftpd user can use to change his password, I also wrote another PHP script that monitors passwords and if a password is about to expire (90 days), it sends out an email to the user.

Now, what I need help with is when a user enters a new password, I don't want this new password to match his previous 6 passwords.

View Replies !
Changing The From Name In Mail()
I know how to send mail with the mail() function. I have looked at the documentation for php and I can not seem to get the right syntax for changing the return name. I am sending mail from my server and it uses the nobody user for the admin of apache. because of this all mail comes in from "nobody". This is really annoying me and if anybody knows the syntax I would sure appreciate it.

View Replies !
Changing Colors
I have this form where you can submit a DJ line up for an event. I want the user to be able to change the font color whenever they wish, and when they hit enter, for it to skip a line. I would like the to be able to do this without them knowing how to use the <br> and <font> commands. Kind of like you see on a phpBB board or something


But is there a way to make this button, and when the click it, it keeps the text that they have already entered into the textarea adds a [ i ] or whater and then when they click the button again, it inserts the [/ i ] without altering the text they already typed. it would be much like the buttons you use to do your PHP and color changes in this forum, but without the pop-up window to enter your code into.

View Replies !
Changing Date?
In MySQL database the date format is as follows:

YYYY-MM-DD

But how can I make it so that when I see it on the page it will be as follows, which is English format:

DD-MM-YYYY

View Replies !
Changing The ROOT_DIRECTORY
I am using XAMPP (latest version) I have got MySQL, PHP, Apache etc..

I wanted to change the root directory shown in PHPINFO(); for XAMPP for my
localhost://

Is there an easy way to do this? i am a complete novice and first timer and
I assume that if I change it to 'C:web' my php files (in that directory
will be shown)

View Replies !
Changing Between Times
does anyone know to convert a time string in the form
dd-mm-yyyyThh:mm:ss i.e 2006-08-01T15:45:11-00:00 to a normal unix time
stamp or something that at least I can use to compare to a unix
timestamp.

View Replies !
Changing Php3.ini !!
I need to enable magic_quotes_gpc. I have learned to get to php3.ini through FTP, have changed it's value, and uploaded the file again. However, the value does not seem to change. I am running a dedicated server, and have attempted to reboot the server. Any ideas to why the settings won't change? Could permissions be a factor?

View Replies !
Changing Session Name
Anyone know how vBulletin changes their session name from the default PHPSESSID to just a simple 's', I thought it would just be a case of: PHP Code:

View Replies !
Changing A String
I've got a form to upload a file. When a file is submitted I need to change the file name before I add a reference of it to the database or copy it to a location on the server.

So let's say I submit the file "test.txt" I need change the file name to "test revision 1.txt" So I need to find the last instance of "." then move back 1 space and add " revision 1" to the string. Anyone know which functions I would have to use?

View Replies !
Changing The Location Of Php.ini
Does anybody know how to change where PHP looks for the php.ini file? It currently looks for the .ini file in /usr/local/lib. I need to change this so it looks at /home/john/usr/local/lib.

View Replies !
Changing Sizes
I have included the content on my site from another file and want the divide to automatically adjust its self to the size of the included content. In internet explorer this is not an issue, however in Firefox, Opera and I suspect Mozilla, the content overflows and the divides of the page do not automatically adjust.....

View Replies !
Changing Tables
I have my main index.php page and I've been looking around for the simplest way to do this but haven't been able to find anything that suits the purpose. Perhaps you guys can help, since you're the best..

All I want to do is switch the table that is in the middle of the page that displays the content of the page. So if someone clicks on, for example, index.php?files it'll change the table to the files table that I have in an html file or something.

View Replies !
Changing Header
I have a website that I need to change the Header and center it. How do I do that? The files are in the CMS files.

View Replies !
Changing Linebreaks To &lt;BR&gt;
When submittin a form, is there a way to change linebreaks to a <BR>? I know you can use ereg_replace() to replace certain characters, or set of characters, but how to specify a line break?!?

View Replies !
Changing Permission
I have been working with uplaoding of images which creates the folder automatically during uplaoding, but iam unable to change the permission of the folder. when i try changing from cpanel i get the below error.
"a fatal error or timeout occurred while processing this directive"
Kindly suggest me where iam wrong.

View Replies !
Session Id Keeps Changing
--when i set session.cache_limiter = private i get this
Set-Cookie: PHPSESSID=61fdf683fef689d5371a1c01fd46e678; path=/; secure
Expires: Thu, 19 Nov 1981 08:52:00 GMT
No idea where it's pulling that date from. (Clearly already expired)

--when i set session.cache_limiter = private_no_expire i get this
Set-Cookie: PHPSESSID=61fdf683fef689d5371a1c01fd46e678; path=/; secure
(no Expires line)
But my session ID still changes every time i refresh the page.

What do I have set wrong?

php.ini
[Session]
; Handler used to store/retrieve data.
session.save_handler = files
session.save_path = /tmp
session.cookie_secure = 1
session.use_only_cookies = 1
session.name = PHPSESSID
session.auto_start = 0
session.cookie_lifetime = 0
session.cookie_path = /
session.cookie_domain =
;session.serialize_handler = php
session.serialize_handler = wddx
session.gc_probability = 1
session.gc_divisor = 100
session.gc_maxlifetime = 1440
session.bug_compat_42 = 0
session.bug_compat_warn = 0
session.referer_check =
session.entropy_length = 16
session.entropy_file = /dev/random
;session.cache_limiter = nocache
session.cache_limiter = private_no_expire
session.cache_expire = 180
session.use_trans_sid = 1




View Replies !
Changing Titles
What I'm trying to do is have a different title per article written on my website.  The way the site is run now, the server calls on an include file, but the browser still reads it as the title for the index.php.

View Replies !
Changing To HTML?
I have a piece of text which is entered into my database, this text contains HTML.

When I output it onto the page I want the HTML to turn into HTML and do what it is supposed to do, instead of just being normal text. How would I do this?

View Replies !
Redirecting And Changing The URL
I have a login page which remembers what you were trying to access, then uses header('Location: url here') to redirect the user back to what they were trying to access after a successful password.

However, the URL remains my.domain.here/login.php, instead of where they were redirected to... which breaks my relative links if they are redirected to a page within a subdirectory.

View Replies !
Changing From Alphabetical
I have had a developer to create a back end for my website.  I can't get hold of him, and to be fair I have bothered him enough, as I am trying to learn as well   That was not his job to teach me!!

What I have is three pictures and text title sitting next to each other, and they are in alphabetical order...What I want to do is place the picture and text title in a different order. Code:

View Replies !
Changing Timezones
I have the date being pulled in an echo statement but I'm trying to use the date_add() function somewhat unsuccessfully... Declaring the current time...

<?php
$time = date("h:i A");
?>

and then echoing it..

<?php echo $time date_add(INTERVAL 2 HOUR)"; ?>

And as guess, it isn't working and even after searching on google, I can't seem to get this one.

View Replies !
Changing The Extention
i just added the following to the htacess file on the server to get php5 working

AddHandler x-httpd-php5 .php

problem is when i try to open the dir on the localhost it will not open. ive tryed deleting the htacess file but this does not help. The message is "you have chosen to open  which is a :application/xhttp-php from http://localhost  what should firefox do with this file?

View Replies !
Changing Db Within Page
I have a php page that flips between dbs and sometimes it works and sometimes it doesn't... e.g. the first query runs from this db, the second query runs from a different db and then the third query runs from the first db again... the first query will run, the second query will run, but then the third query will not.

Each time that I switch to a query that calls a different db, I used include_once "db_whatever"; before the query, thinking that, that would work, but it doesn't... Is there something I need to do to kill the previous db connection prior to moving onto another one?

View Replies !
Changing File Name
I'm trying to upload a picture and also reference its location to a mysql database. When the file is uploaded I want it to change its name to something random (with no spaces). I have the following script but when I run it it says QuoteSorry, there was a problem uploading your file. Code:

View Replies !
Changing Variables
i have some code that a form sends data to (this part works) i have it so if they order 2 or more the price is different to if they just order 1 ( a discount.)But if any of the boxes are left at zero(0) it still charges them a small fee. And when i try to change a variable in an if statement it does not work. Code:

View Replies !
Changing Field Value + PHP
I want to populate a field with a database tables data based on a users selection. The user selects an investment type from a select menu. The select menu is populated by database table. Code:

View Replies !
Changing A Page
is it possible to change a page eg:

http://www.domain.com/index.php?page=home

what is the best way of doing this? would the code be similar to this:

PHP Code:

<?PHP $page = $_GET['page'];
if ($page = 'home'){

include("home.php");

}else{

include("error.php");

} ?>

View Replies !
Changing Page
what the ?action= thing is at the end of a url... not what it is just what i could search for so i can find some tutorials to get more knowledge of it. I already know some stuff i just need to refresh my memory and learn how to use them effectively and stuff. (?action= was an example).

View Replies !
Changing The Case
I wrote my whole code using lowercase image names and saved my images as uppercase. The problem now is that I have many, many image files that won't be viewed because my server is searching for the lowercase version of the files (which do not exist). I'm not too competent on directories in php, I just know enough to make simple scripts. Can anyone show me a way to set all the file names of a directory into an array, or if you are willing, to do that and change them to lowercase?

View Replies !
Changing Color
how can i change the color of $text3.i tried with html and css its coming but i dont know how to embed with php PHP Code:

<html>
<body>
<form method="POST" action="textbox.php">
Enter The Text:<input type="text" name="text">
<INPUT TYPE="submit" name="ok" value="ok"></form>
<?php

if(isset($_POST['ok']))
{
$text3=$_POST['text'];
$para = " how are you Mr.$text3? ";
echo $para ."<br>";
//echo str_replace("hello",$text3,$para);
}
?>

View Replies !
Changing /view.php
I'm trying to figure out how to change the display of the URL from /view.php?q=page.htm to a simple /view/page.htm where /view/ is still a PHP script. Can anybody help me or guide me where I can get information on this.

View Replies !
Changing Row Type
while ($qry = mysql_fetch_array($p_edu)) {
print "
<tr>
<td>$qry[cYear]</td>
<td>$qry[Education]</td>
<td>$qry[School]</td>
<td>$qry[Program]</td>
<td>
<form name='form1' method='post' action=$PHP_SELF>
<input name='delid' type='hidden' value=$qry[id]>
<input type='submit' name='delete' value=Delete>
</form>
</td>
</tr>
";
}


[edited by: ergophobe at 6:03 pm (utc) on Feb. 26, 2005]
[edit reason] made code readable - linebreaks [/edit]

View Replies !
Changing Fonts In GD
I posted this problem at another board and haven't recieved a clearcut answer as of yet. Yes, they gave me a few good places to look for the problem, but nothing has helped yet.

I have written a script that writes several lines of text to an image. This is not all that difficult UNTIL I attempted to use an array to change the font for each line of text.

Is it possible with GD to change fonts midstream in this mannor? Code:

View Replies !
Changing Format
I am extracting data from a database and creating a report. The date in the database is stored in the format YYYY-MM-DD HH:MM:SS but when i display the report i just want the date to be displayed as MM/DD

View Replies !
Changing Date
how to advance a date like 15 days from today would be :

$next_month = time() + (15 * 24 * 60 * 60);
$fifteen_days_depart = date(Ymd, $next_month);

my question is if i had a date like tomorow 20060420 and wanted to go 15 days from that how would i do that with out the numbers reading 20060435?

View Replies !
Changing Pages
What is the correct way of moving to a new page?

normally i would do:

include "newpage.php"

when I wanted to display newpage.

Is this the best way or is there another (better) way?

View Replies !
Changing Languages
I'm currently working on a website that people from around the world uses it to send messages in their own languages to the refugee camps. Because it is for the World Expo in Japan, I currently set the database to Japanese (ja-sjis) so that it can record both English and Japanese.

When I tried to enter a language like Thai into the database, everything showed up as "???". Is there a way to fix this problem? My idea was to use PHP coding to detect the language and change the language of mySQL, but I have no idea how to do that. It seems like if I change the language of the database to the right language then I can enter a message in that language.

View Replies !
Changing A Variable
Heres a bit of code that gets the contents of a directory and lists it as links to the filename: PHP Code:

<?php

$path = "h:media";
$dh = opendir($path);
$i=1;
while (($file = readdir($dh)) !== false) {
    if($file != "." && $file != "..") {
        echo "$i. <a href='$file'>$file</a><br />";
        $i++;
    }
}
closedir($dh);
?>

What I want to do is have it so that clicking a link, instead of trying to open the file, reloads the page with $file as the new value of $path so that it can navigate directory structure *except* when $file isn't a directory, in which case I want it to open the file.

View Replies !
Changing Fonts Etc In Php
I've setup a membership script but I would like to know where I can insert code to change font / background etc on the php page? For example, how would I change the font for the 'could not establish connection' text below.

mysql_connect($server,$dbuser,$dbpass) or die ("Could not establish connection"); // make connection

View Replies !
Changing Servers
In the next few days I plan to change servers with my website. This is because a new version of my site is planned which will be coded in ASP.NET 2.0. Because of this my host has said I need to change servers which will of course change my path.

However it will still be a few months until the new version is released and meanwhile we will be using the current version of the site which is coded in PHP. It uses databases through 'phpmyadmin'. I don't know much about this, but Im sure most of you will.

My question is will I have to change any paths in the PHP files (including the .inc files etc) or will the site still run OK with a new server? If the path does need changing on some parts of the code, where is the most common place for the path to be mentioned?

View Replies !
Changing Web Page
I have a PHP page which displays tabular data across 20 columns. I want to print this page in landscape orientation from Internet Explorer 6. How can I do this?

View Replies !
Variable Changing
Is there any way to have a variable change depending on the line of text its on?
i.e.

if (line=1){
$variable = hello;
}
if (line=2){
$variable = goodbye;
}

echo $variable . '<br>' . $variable;

Would output.

View Replies !

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