runnerjp Posted November 9, 2008 Share Posted November 9, 2008 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 More sharing options...
.josh Posted November 9, 2008 Share Posted November 9, 2008 Can you rephrase that? Link to comment https://forums.phpfreaks.com/topic/132025-solved-arrays/#findComment-686022 Share on other sites More sharing options...
runnerjp Posted November 9, 2008 Author Share Posted November 9, 2008 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 More sharing options...
wildteen88 Posted November 9, 2008 Share Posted November 9, 2008 I think you mean 'message' => '> topic:' . $gettopic3['title'] , Not 'message' => '> topic:' echo $gettopic3['title'] , You use the . to concatenate strings together. Link to comment https://forums.phpfreaks.com/topic/132025-solved-arrays/#findComment-686035 Share on other sites More sharing options...
runnerjp Posted November 9, 2008 Author Share Posted November 9, 2008 ahh thanks Link to comment https://forums.phpfreaks.com/topic/132025-solved-arrays/#findComment-686042 Share on other sites More sharing options...
.josh Posted November 9, 2008 Share Posted November 9, 2008 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 More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.