...

View Full Version : Changing contents of a variable to what matches in a language.php file



obloxeon
04-30-2009, 07:10 AM
I'm curious as to how I go about solving this problem. I get input from the user and store it in a variable. I want the contents of that variable to be replaced by the text in the language file.

Example:

User types in "GOOG" stores it in a variable $ticker and then contents of the variable are replaced by the text found in language.php:


'GOOG' => "Google",


How do I go about doing this? Then assuming the variable's contents can be replaced, would I just echo $ticker and it would display Google?

Fumigator
04-30-2009, 05:36 PM
Is this language.php file something you wrote? What's in it? How would we know anything about it?

obloxeon
04-30-2009, 06:14 PM
Is this language.php file something you wrote? What's in it? How would we know anything about it?

Yes, I wrote it and I gave an example of what would be in it, among other tickers. I want the instances of GOOG to be replaced with Google if they entered that or Apple if they entered AAPL. Would I be better off defining a constant and taking the data from the variable to fill it? Even then, how would I go about changing the input?

obloxeon
05-03-2009, 04:47 PM
Any ideas?

Len Whistler
05-04-2009, 12:01 AM
This should give you an idea were to start.


<?php
$post_result = $_POST['ticker_symbol'];
$ticker_symbol = strtoupper($post_result); // output uppercase

switch ($ticker_symbol) {

case 'GOOG':
$ticker = "Google";
break;

case 'AAPL':
$ticker = "Apple";
break;

case 'QQQQ':
$ticker = "PowerShares QQQ";
break;

case 'USD':
$ticker = "US Dollar";
break;

default:
$ticker = "Sorry invalid input";
break;

}

echo "$ticker";
?>

<form method="post" action="<?php echo $PHP_SELF;?>">
<input type="text" size="6" maxlength="6" name="ticker_symbol">
<input type="submit" value="Enter Ticker Symbol" name="submit">
</form>


---

damon.whitt
05-04-2009, 05:49 AM
define("GOOG","Google");



echo GOOG;

Let me know if this helps



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum