Jump to content

"00000E00" not being treated as string?


aobrien5

Recommended Posts

I've got a big switch/case statement to translate file names into readable text.  Our programmers chose to use hex strings to describe different parts of the files, and all of my cases are working fine except one.

 

	switch ($profile) :
             <snip>
	case "00001800":
	    $r .= " Live+7 ACM";
	    break;
	case "00001C00":
	    $r .= " Live+75 ACM";
	    break;
	case "00000E00":
	    $r .= " Live+3";
	    break;
	case "00000802":
	    $r .= " Hispanic Live+7";
	    break;
	default:
	    $r .= "";
endswitch;

 

All of the cases above work fine (including those snipped) except case "00000E00".  I've verified that the $profile contains the same string, but it get's translated as default.  Is it being treated as a hex number for some reason?  If so, why aren't all the others?

 

I'm completely baffled on this one.  I've tried storing the case string as a variable and that didn't help.  I tried modifying the $profile and case to "10000E00" and that works fine.  I tried modifying the $profile and case to "00001E00" and that ended up getting translated as a different number altogether.

 

Does this mean I need to ensure that $profile is being treated as a string?  How should I do that?

Link to comment
Share on other sites

Actually, I did try that as well, and it didn't help.  The more I write about this, the more I think it's related to the variable in $profile not being of the right format.  That's being gathered from this part of the code:

 

list($market, $period, $geography, $service, $profile, $other) = explode("_", $filename);

 

where $filename = CHI_0807_12_00000004_00000E00_0

 

Thanks.

Link to comment
Share on other sites

The bits of posted code actually work. That would mean that the $profile variable is being accessed as a number somewhere between where it is set and where it is tested in the switch/case statement.

 

Please post the relevant code.

maybe not

try

<?php
$a = '001';
switch ($a):
case  '1':
	echo 'ok';
break;
default:
	echo 'no';
break;
endswitch;
?>

Link to comment
Share on other sites

Like I stated, just the posted pieces of code work -

<?php
$filename = "CHI_0807_12_00000004_00000E00_0";
list($market, $period, $geography, $service, $profile, $other) = explode("_", $filename);
echo $profile;
$r = "";
switch ($profile) :
	case "00001800":
	    $r .= " Live+7 ACM";
	    break;
	case "00001C00":
	    $r .= " Live+75 ACM";
	    break;
	case "00000E00":
	    $r .= " Live+3";
	    break;
	case "00000802":
	    $r .= " Hispanic Live+7";
	    break;
	default:
	    $r .= "";
endswitch;
echo $r;
?>

 

You would need to post all the relevant code for anyone in a forum to be able to duplicate and find what exactly your code is doing.

 

Edit: I'm going to take a guess that the variable gets passed as a parameter in a function call at some point.

Link to comment
Share on other sites

Actually that's fascinating.  As I mentioned, I snipped a few cases above those posted.  Put this case in as the first one, and it breaks:

 

case "00000000":
    break;

 

Edit: If you still want the whole function, I can post it.  However, $profile is not passed into the function.

 

Edit2: case $profile==="00000000" makes everybody happy.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.