Webmaster Forum


Go Back   Webmaster Forum > Web Development > Coding Forum

Coding Forum Problems with your code? Discuss coding issues, including JavaScript, PHP & MySQL, HTML & CSS, Flash & ActionScript, and more.


Closed Thread
 
LinkBack Thread Tools Display Modes
Share |
  #1 (permalink)  
Old 08-11-2012, 01:29 AM
Banned
 
Join Date: 08-02-12
Location: USA
Posts: 23
iTrader: 0 / 0%
Variable inside of an array (PHP)

Pardon my ignorance, I'm not much of a coder. I tinker, but that's about it.

Anyhow, as the title suggest I am having a problem loading a variable inside of an array. Or better yet, setting the value of the array from a variable. I'm not sure if that makes sense so I'll just show examples:


Below is what I am trying to accomplish, I want to define the $links variable inside config.php

PHP Code:
.
.
.
@require(
"config.php");
    
$okfiles = array($links);
.
.

However, that does not work.


PHP Code:
.
.
.
@require(
"config.php");
    
$okfiles = array('link1','link2','link3','etc');
.
.

This works, and is how I currently have it setup but it's not what I want.


Make sense?
 
  #2 (permalink)  
Old 08-11-2012, 02:55 AM
lordspace's Avatar
Contributing Member
 
Join Date: 05-30-06
Location: Canada
Posts: 913
iTrader: 0 / 0%
actually, it should work but in the first non-working example you're inserting an array in the first array item.

maybe you could use

Code:
$okfiles = $other_array + $okfiles
 
  #3 (permalink)  
Old 08-11-2012, 03:57 AM
Super Moderator
Latest Blog:
None

 
Join Date: 11-11-11
Location: Copenhagen, Denmark
Posts: 1,739
iTrader: 0 / 0%
If you just want to make an array equal to another array, you can use something like this:
PHP Code:
$okfiles $files
If you want to merge to arrays, you can use:
PHP Code:
$okfiles array_merge($okfiles$files); 
If you want to append a new item to an array:
PHP Code:
$newItem "The link";
$okfiles[] = $newItem
__________________
Need a break? EnterCave more than 40000 online games in 15 categories.
Search or browse through EnterCave Online Games Directory
 
Go Back   Webmaster Forum > Web Development > Coding Forum

Closed Thread


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

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 Off
Pingbacks are Off
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Are variable links possible? c.eiermann Coding Forum 6 12-10-2011 10:09 PM
PHP variable inside CSS file roice Coding Forum 3 03-10-2010 05:35 AM
Can a store php/mysql commands inside a variable? RyOn Coding Forum 0 03-10-2010 02:37 AM
Use variable as an array argument levani Coding Forum 3 08-04-2009 07:03 AM
For fun: Delete an array from array kos Coding Forum 3 05-30-2009 10:33 AM


V7N Network
Get exposure! V7N I Love Photography V7N SEO Blog V7N Directory


All times are GMT -7. The time now is 03:08 AM.
Powered by vBulletin
Copyright © 2000-2013 Jelsoft Enterprises Limited.
Copyright © 2003 - 2013 Escalate Media LP




Search Engine Optimization by vBSEO 3.6.0 RC 2 ©2011, Crawlability, Inc.