473,785 Members | 2,887 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Trying to get constant from array but get literal string instead

[PHP]
var $filterArray = array('reverse' =IMG_FILTER_NEG ATE,
'edge highlight' =IMG_FILTER_EDG EDETECT,
'emboss' =IMG_FILTER_EMB OSS,
'gaussian blur' =IMG_FILTER_GAU SSIAN_BLUR,
'blur' =IMG_FILTER_SEL ECTIVE_BLUR,
'sketchy' =IMG_FILTER_MEA N_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:

<option value="IMG_FILT ER_EMBOSS">embo ss</OPTION>
Which is completely wrong; I want the actual constant IMG_FILTER_EMBO SS
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 &generateFilter Dropdown($newFi lterArray = '') { // STATIC
HTML STRING METHOD
if (!is_object($th is) || @!is_a($this,
'ImageFilterTec hniqueGenerator ')) {
$self =& new ImageFilterTech niqueGenerator( 'placeholder');
} else {
$self =& $this; // MAKE A LOCAL REFERENCE POINTER TO KEEP
CODE CONSISTENT
}
if (is_array($newF ilterArray) && @sizeof($newFil terArray) 0)
$self->setFilterArray ($newFilterArra y);
$filterArray = $self->getFilterArray ();
if (is_array($filt erArray) && @sizeof($filter Array) 0) {
$html = "<select multiple name=\"filter_t ech[]\" size=\"";
$html .= (sizeof($filter Array) 5) ? 5 : sizeof($filterA rray);
$html .= "\">\n";
foreach ($filterArray as $display =$filter) {
print_r("filter = $filter = ${$filter}<P>") ; // THIS PRODUCES
"filter = IMG_FILTER_EMBO SS =
$html .= " <option value=\"${$filt er}\"" .
$self->disp->preSelect(${$f ilter},
@array_search(a rray_values($fi lterArray), ${$filter})) . '>' .
str_replace('<' , '&lt;', str_replace('\\ ', '',
$display)) . "</option>\n";
}
$html .= "</select>\n";
}

return $html;
}
[/PHP]

Thanx
Phil

Jul 21 '06 #1
2 2330
comp.lang.php wrote:
[PHP]
var $filterArray = array('reverse' =IMG_FILTER_NEG ATE,
'edge highlight' =IMG_FILTER_EDG EDETECT,
'emboss' =IMG_FILTER_EMB OSS,
'gaussian blur' =IMG_FILTER_GAU SSIAN_BLUR,
'blur' =IMG_FILTER_SEL ECTIVE_BLUR,
'sketchy' =IMG_FILTER_MEA N_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:

<option value="IMG_FILT ER_EMBOSS">embo ss</OPTION>
Are you using PHP 5? Those are PHP 5 constants, and if they don't exist
the constant will be converted to that string. Just try var_dump(
IMG_FILTER_NEGA TE ); via command line or in a script to see if the
numeric value is returned. Otherwise, I'd try wrapping the constants
like the following
'reverse' =intval( IMG_FILTER_NEGA TE ),

Jul 21 '06 #2

bobzimuta wrote:
comp.lang.php wrote:
[PHP]
var $filterArray = array('reverse' =IMG_FILTER_NEG ATE,
'edge highlight' =IMG_FILTER_EDG EDETECT,
'emboss' =IMG_FILTER_EMB OSS,
'gaussian blur' =IMG_FILTER_GAU SSIAN_BLUR,
'blur' =IMG_FILTER_SEL ECTIVE_BLUR,
'sketchy' =IMG_FILTER_MEA N_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:

<option value="IMG_FILT ER_EMBOSS">embo ss</OPTION>

Are you using PHP 5? Those are PHP 5 constants, and if they don't exist
the constant will be converted to that string. Just try var_dump(
IMG_FILTER_NEGA TE ); via command line or in a script to see if the
numeric value is returned. Otherwise, I'd try wrapping the constants
like the following
'reverse' =intval( IMG_FILTER_NEGA TE ),

Thanx but I am using PHP 4.1.2 on one machine, PHP 4.3.2 on another
machine, PHP 4.3.9 on another machine and PHP 5.0.4 on another machine,
all test machines for building a portable web application product. So
I can't have anything specific to PHP 5.0+ without having to come up
with a PHP 4+ version, and I can't imagine a version for that, so I'm
scrapping the whole filter thing.

Thanx though
Phil

Jul 21 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
10232
by: Mike S. Nowostawsky | last post by:
I tried using the "toUpperCase()" property to change the value of an array entity to uppercase BUT it tells me that the property is invalid. It seems that an array is not considered an object when it is assigned a text literal?? HOW can I change the array value to upper case then? What other method exists for arrays? Ex: var GridArrayName1 = new Array(); GridArrayName1 = new Array ('test-value'); GridArrayName1 = GridArrayName1...
7
1675
by: Yodai | last post by:
Hi all... I am trying to construct an 2x14 array that compares a given character with the 1st column of data type "t" and returns the second column's appropriate value "v". I've been trying this, but doesn't seem to work.... Any idea of what I am missing? void Detect_type(void) { volatile char r1tipus = *R1TIPUS; unsigned char cadena = {
7
3798
by: Sam Kong | last post by:
Hello! My question would not be very practical but just out of curiosity. In JavaScript, Array is a subclass of Object. Well maybe not exactly... but sort of... For normal objects, you can access members by writing either of the two. obj.memberName
3
2354
by: lovecreatesbeauty | last post by:
Both `K&R C, 2nd' and `C: A reference manual, 5th' introduce the "hello, world" thing using the name "string-constant". But `ISO/IEC 9899:TC2' does not include this kind of thing in section `A.1.5 Constants'.
6
1638
by: chandanlinster | last post by:
hello everybody, consider the following statement, char *s = "someString"; Does the above statement cause "someString" to be alloted a constant memory space. What I mean is can't we manipulate "someString" using statements like s = 'a';
4
1743
by: Quentin Yuan | last post by:
I always consider that the constant character strings of which literal value are the same lay out at the same logic address, in another words, every constant character string have only one copy in the program. My view base on that if it doesn't that, you lose the memory of the string that you have used except store the address in a pointer, this is a form of memory leak although it doesn't really eat the memory as the general memory leak....
20
691
by: karthikbalaguru | last post by:
Hi, String constant being modifiable in C++ but, not modifiable in C. that is, In C++, the following example output will be "Mplusplus" char *str1 = "Cplusplus"; *str1 = 'M'; In C, the above example will produce an error as we are trying to modify a constant. So, str1 is not a string constant in C++.
18
1930
by: sinbad | last post by:
hi, why does the following program gives an runtime error ,instead of compilation error. anyone please shed some light. thanks sinbad ------------------------------ int main()
10
1952
by: tech | last post by:
Hi, I need to define some strings in a header file, they are to be const Whats the best to choose from below; const std::string s = "Hello"; const char* s = "Hello"; char* s = "Hello"; Thanks
0
9645
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9480
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10153
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10093
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9952
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8976
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5511
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3654
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2880
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.