Reply to Trying to get constant from array but get literal string instead

Your name:

Reply:


Posted by comp.lang.php on 12/17/11 11:53

[PHP]
var $filterArray = array('reverse' => IMG_FILTER_NEGATE,
'edge highlight' => IMG_FILTER_EDGEDETECT,
'emboss' => IMG_FILTER_EMBOSS,
'gaussian blur' => IMG_FILTER_GAUSSIAN_BLUR,
'blur' => IMG_FILTER_SELECTIVE_BLUR,
'sketchy' => IMG_FILTER_MEAN_REMOVAL);

[/PHP]

I am trying to generate an HTML dropdown from this array, however, when
I do, the value that should go in the OPTION tag literally becomes
this:

[quote]
<option value="IMG_FILTER_EMBOSS">emboss</OPTION>
[/quote]

Which is completely wrong; I want the actual constant IMG_FILTER_EMBOSS
instead, which should display as an integer within the OPTION tag.

How do I do this?

Code:

[PHP]
/**
* Generate a filter technique dropdown HTML with any additional
features to the array before display
*
* *NOTE* This method will be called outside of the $this->image
property having existence and thus will have to be used as a
placeholder to self-instantiate using $this->self
*
* @access public
* @param array $newFilterArray (optional)
* @return mixed HTML
*/
function &generateFilterDropdown($newFilterArray = '') { // STATIC
HTML STRING METHOD
if (!is_object($this) || @!is_a($this,
'ImageFilterTechniqueGenerator')) {
$self =& new ImageFilterTechniqueGenerator('placeholder');
} else {
$self =& $this; // MAKE A LOCAL REFERENCE POINTER TO KEEP
CODE CONSISTENT
}
if (is_array($newFilterArray) && @sizeof($newFilterArray) > 0)
$self->setFilterArray($newFilterArray);
$filterArray = $self->getFilterArray();
if (is_array($filterArray) && @sizeof($filterArray) > 0) {
$html = "<select multiple name=\"filter_tech[]\" size=\"";
$html .= (sizeof($filterArray) > 5) ? 5 : sizeof($filterArray);
$html .= "\">\n";
foreach ($filterArray as $display => $filter) {
print_r("filter = $filter = ${$filter}<P>"); // THIS PRODUCES
"filter = IMG_FILTER_EMBOSS =
$html .= " <option value=\"${$filter}\"" .
$self->disp->preSelect(${$filter},
@array_search(array_values($filterArray), ${$filter})) . '>' .
str_replace('<', '&lt;', str_replace('\\', '',
$display)) . "</option>\n";
}
$html .= "</select>\n";
}

return $html;
}
[/PHP]

Thanx
Phil

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация