Jump to content

[SOLVED] arrays


runnerjp

Recommended Posts

how would i  get this to work??  'message' => '> topic:'  echo $gettopic3['title'] ,

 

<?php $show = array(
  'message' => '> topic:'  echo $gettopic3['title'] ,
  'post' => '> Start new topic', 
  'reply' => '> reply to a post' 
);
if(in_array($_GET['page'],array_keys($show))) {
  echo $show[ $_GET['page'] ];
} ?>

Link to comment
https://forums.phpfreaks.com/topic/132025-solved-arrays/
Share on other sites

ok well basicly my code was working with

 

<?php $show = array(

  'message' => '> topic:' ,

  'post' => '> Start new topic',

  'reply' => '> reply to a post'

);

if(in_array($_GET['page'],array_keys($show))) {

  echo $show[ $_GET['page'] ];

} ?>

 

but i want to add $gettopic3['title'] so it shows the user which topic they are on... so really my question is how cna i add $gettopic3['title'] into my array for 'message'

Link to comment
https://forums.phpfreaks.com/topic/132025-solved-arrays/#findComment-686034
Share on other sites

wildteen beat me to it earlier, but I was also going to tell you that array key=> value assignments is just like a regular variable assignment, with . for concatonations, single/double quote rules, etc... Example:

 

$blah = 'something';

$blah = 'something' . $something;

$blah = "something$something";

etc...

Link to comment
https://forums.phpfreaks.com/topic/132025-solved-arrays/#findComment-686055
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.