这个问题已被修改为反思我正在接近这个问题 错。
我需要做的只是显示突出显示的值,所以如果 LLOBLEVEL小于ILEVEL它突出显示屏幕上的值。 因此,排除不等于小于ILEVEL的输出<。
任何帮助都会很受欢迎。
<script type="text/javascript">
<!--
function toggle_visibility(id) {
var e = document.getElementById(id);
if(e.style.display == 'block')
e.style.display = 'none';
else
e.style.display = 'block';
}
//-->
</script>
<script type="text/javascript">
function toggle(it) {
if ((it.style.backgroundColor == "none") || (it.style.backgroundColor == ""))
{it.style.backgroundColor = "#CCC";}
else
{it.style.backgroundColor = "";}
}
</script>
<?php include 'levels.php'; ?>
</head>
<body>
<?php
$total = count($lloblevel_val);
for ($i=0; $i< $total; $i++) {
$name = '';
$level = '';
$lob = '';
if ($iname_val[$i]) {
$name = '<span id="title">' . $iname_val[$i] . '</span><br/>';
}
if ($ilevel_val[$i] < $lloblevel_val[$i]) {
$level = '<span class="highlight">' . $ilevel_val[$i] . '</span><br/>';
}
if ($lloblevel_val[$i] > $ilevel_val[$i]) {
{
$lob = '<span class="highlight">' . $lloblevel_val[$i] . '</span><br/>';
}
?>
<table id="highlighted">
<tr onClick="toggle(this)">
<td class="tdl"><?php print $name; ?></td>
<td class="tdr"><?php print $lob; ?></td>
<td class="tdr"><?php print $level; ?></td>
</tr>
</table>
<?php } ?>
<?php } ?>
</body>
</html>
levels.php
<?PHP
$file_handle = fopen("stockexport.csv", "r");
while (!feof($file_handle) ) {
$line_of_text = fgetcsv($file_handle, 1024,",");
if(!$next_line) {
$iname_val[] = $line_of_text[1];
$ilevel_val[] = $line_of_text[5];
$lloblevel_val[] = $line_of_text[3];
}
}
fclose($file_handle);
?>
答案 0 :(得分:0)
您可以在$line_of_text
数组中搜索您不想要的单词。
while (!feof($file_handle) ) {
$line_of_text = fgetcsv($file_handle, 1024,",");
$words_to_discard=array("DESKTOP PC","another word","0337"); //here, you put all the wors to discard
foreach ($words_to_discard as $word){
if(stristr($line_of_text[1],$word) !== FALSE)
$next_line=1;
}
if(!$next_line) {
$iname_val[] = $line_of_text[1];
$ilevel_val[] = $line_of_text[5];
$lloblevel_val[] = $line_of_text[3];
echo $line_of_text[1]."-". $line_of_text[5]."-". $line_of_text[3]."<br>";
}
}
修改
使用此代码,使用此csv文件(您的csv文件):
ItemNumber,ItemTitle,Level,MinimumLevel,InOrderBook,Level_LessOrderBook
"VBI4-0332","DES2OP PC--- VBI4-0332","20","0","0","20"
"VBI4-0333","DESKTOP PC--- VBI4-0333","20","0","0","20"
"VBI4-0334","DESKTOP PC--- VBI4-0334","20","0","0","20"
"VBI4-0335","DESKTOP PC--- VBI4-0335","20","0","0","20"
"VBI4-0336","DESKTOP PC--- VBI4-0336","20","0","0","20"
"VBI4-0337","DESKTOP PC--- VBI4-0337","20","0","0","20"
将输出:
ItemTitle-Level_LessOrderBook-MinimumLevel
DES2OP PC--- VBI4-0332-20-0
答案 1 :(得分:-1)
这样的事可能会有所帮助
if (preg_match("DESKTOP PC", $array))
{
Do something
}
此处还有一个解释它的链接http://uk3.php.net/preg_match