Current location: Hot Scripts Forums » Programming Languages » PHP » Easy question about arrays...


Easy question about arrays...

Reply
  #1 (permalink)  
Old 03-07-04, 06:31 PM
tempa tempa is offline
Newbie Coder
 
Join Date: Mar 2004
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Post Easy question about arrays...

Heres the code my current script produces

Array
(
[0] => Array
(
[name] => TEXT
[instances] => Array
(
[0] => Array
(
[contents] => hello
)

[1] => Array
(
[contents] => goodbye
)

What would i need to do to convert this code to something like:

TEXT0="hello"
TEXT1="goodbye"

Any ideas? Thanks in advance!
Reply With Quote
  #2 (permalink)  
Old 03-08-04, 10:24 AM
NeverMind's Avatar
NeverMind NeverMind is offline
Community VIP
 
Join Date: Aug 2003
Location: K.S.A
Posts: 2,257
Thanks: 0
Thanked 2 Times in 1 Post
you are using multi-dimensional arrays I don't know why but in your situation it seems useless
use one dimension array.. but it's really up to you

foreach is a good solution for arrays:
PHP Code:

foreach ($array as $key => $value) {

  echo 
"$key = \"$value\"";

__________________
PHPSimplicity
We don't need a reason to help people - Zidane [FF9]
Reply With Quote
  #3 (permalink)  
Old 03-08-04, 10:59 AM
tempa tempa is offline
Newbie Coder
 
Join Date: Mar 2004
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
where would i place this code though?

Thanks for the help so far!
Reply With Quote
  #4 (permalink)  
Old 03-08-04, 11:10 AM
NeverMind's Avatar
NeverMind NeverMind is offline
Community VIP
 
Join Date: Aug 2003
Location: K.S.A
Posts: 2,257
Thanks: 0
Thanked 2 Times in 1 Post
Quote:
Originally Posted by tempa
where would i place this code though?

Thanks for the help so far!
where ever you want in your php script
but one thing,, if you want the word TEXT# you gotta use this one:
PHP Code:

$i 0;

 foreach (
$array as $key => $value) { 
  echo 
"TEXT$i = \"$value\""
  
$i++;

but try both and see what will happen
__________________
PHPSimplicity
We don't need a reason to help people - Zidane [FF9]
Reply With Quote
  #5 (permalink)  
Old 03-09-04, 06:13 AM
tempa tempa is offline
Newbie Coder
 
Join Date: Mar 2004
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
I've been working on it all day, thanks to you it's working like a dream now. Thanks a million mate!
Reply With Quote
Reply

Bookmarks


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 Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
question and answer software jaydifox C/C++ 0 02-21-04 09:26 AM
question about updating a page or database for an, php and mysql updating mikewooten PHP 1 02-12-04 12:11 AM
Perl-PHP software Copyright question! kevin PHP 8 10-29-03 08:03 AM
Easy File Manager supports multilanguage !!! HotCGIScripts !!! General Advertisements 2 08-06-03 11:59 AM
Web Stat Question ossi44 New Members & Introductions 2 06-13-03 09:36 AM


All times are GMT -5. The time now is 09:12 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.