Serious Problem
Moderator: General Moderators
Serious Problem
Hi All,
I have a really big problem :)) As you have seen below.....
/*********A PART OF AN ARRAY ($arr)*****************/
..........................
[490] =>
[491] => <marquee border="0" height="18"
[492] => style="font-family: Helvetica ; font-weight:bold; background-color:#000000; color:white; font-size:11px"
[493] => behavior="scroll" align="middle" scrollamount="4">
.....................
/***************************************************/
Now I want to find specific element of this array, let say $arr[491] then I want to use following code,
/****************THE CODE*********************/
$key="<marquee border=\"0\" height=\"18\"";
for ($i=475;$i<515;$i++){
if($arr[i]==$key){ //Problem here.PH.Line3
$start=$i-7;
$i=515;
}
}
echo $start;
if($start){
for ($k=$start;$k<$start+295;$k++){
echo $arr[$k];
}
}
/*********************************************/
But some how, in line 3 $key doesn't match with $arr[491]. I observed this code 4 times. Seriousness of this problem is that I can not see any problem. Please I need someone to help me :)) Thanx to All
I have a really big problem :)) As you have seen below.....
/*********A PART OF AN ARRAY ($arr)*****************/
..........................
[490] =>
[491] => <marquee border="0" height="18"
[492] => style="font-family: Helvetica ; font-weight:bold; background-color:#000000; color:white; font-size:11px"
[493] => behavior="scroll" align="middle" scrollamount="4">
.....................
/***************************************************/
Now I want to find specific element of this array, let say $arr[491] then I want to use following code,
/****************THE CODE*********************/
$key="<marquee border=\"0\" height=\"18\"";
for ($i=475;$i<515;$i++){
if($arr[i]==$key){ //Problem here.PH.Line3
$start=$i-7;
$i=515;
}
}
echo $start;
if($start){
for ($k=$start;$k<$start+295;$k++){
echo $arr[$k];
}
}
/*********************************************/
But some how, in line 3 $key doesn't match with $arr[491]. I observed this code 4 times. Seriousness of this problem is that I can not see any problem. Please I need someone to help me :)) Thanx to All
- twigletmac
- Her Royal Site Adminness
- Posts: 5371
- Joined: Tue Apr 23, 2002 2:21 am
- Location: Essex, UK
Re: Serious Problem
buyukcer wrote:Hi All,
if($arr==$key){ //Problem here.PH.Line3
From a quick glance at the code, I think you might want to change
Code: Select all
if($arrїi] == $key) {Code: Select all
if($arrї$i] == $key) {Mac
- twigletmac
- Her Royal Site Adminness
- Posts: 5371
- Joined: Tue Apr 23, 2002 2:21 am
- Location: Essex, UK
Re: Serious Problem
OK. Looking a bit closer, perhaps the problem is this line:
in the first for loop.
Basically all that loop does is set $i to 475 to start and then you set $i to 515 in the loop. This means that you are only ever testing $arr[475] == $key in the if loop which you know isn't true. Take out the $i=515 bit and the for loop will run more than once.
Mac
Code: Select all
$i = 515;Basically all that loop does is set $i to 475 to start and then you set $i to 515 in the loop. This means that you are only ever testing $arr[475] == $key in the if loop which you know isn't true. Take out the $i=515 bit and the for loop will run more than once.
Mac
But as you see in my code $i=515 is a part of if statement. Actually I wanted to use the line "$i=515" as "break". When I found the right line, I want to end th for loop. So if equality is satisfied $i takes the value 515 and for loop ends. However the real problem is in "if statement". Am I right? Thanks your time, please continue with your suggestions.
- twigletmac
- Her Royal Site Adminness
- Posts: 5371
- Joined: Tue Apr 23, 2002 2:21 am
- Location: Essex, UK
Oops sorry bit sleepy and not paying enough attention.buyukcer wrote:But as you see in my code $i=515 is a part of if statement.
If I run the following code:
Code: Select all
<?php
$arr = array(
490 => '',
491 => '<marquee border="0" height="18"',
492 => 'style="font-family: Helvetica ; font-weight:bold; background-color:#000000; color:white; font-size:11px"',
493 => 'behavior="scroll" align="middle" scrollamount="4"'
);
$key='<marquee border="0" height="18"';
for ($i=475;$i<515;$i++){
if($arrї$i]==$key){
$start=$i-7;
$i=515;
}
}
echo $start;
if($start){
for ($k=$start;$k<$start+295;$k++){
echo $arrї$k];
}
}
?>Isn't that what you're looking for?my browser window wrote:484<marquee border="0" height="18"style="font-family: Helvetica ; font-weight:bold; background-color:#000000; color:white; font-size:11px"behavior="scroll" align="middle" scrollamount="4"
Mac
yes this is a good way of debugging but I have already done this, and result is obvious. I modified the loop like that
/*******new for loop*****/
for($i=475;$i<515;$i++){
if($arr[$i]==$key){
$start=$i-7;
$i=515;
}
else{
echo $i."<br>";
}
/********end************/
as you may guess i saw numbers from 475 to 514. I know something wrong with $key, so you right, but I wonder what is the problem of this string? Why $arr[491] never be equal to $key. I used echo $arr[491] and echo $key lines. And then they gave similar outputs. But indeed, they are not. I should find a way to examine their similarity?
/*******new for loop*****/
for($i=475;$i<515;$i++){
if($arr[$i]==$key){
$start=$i-7;
$i=515;
}
else{
echo $i."<br>";
}
/********end************/
as you may guess i saw numbers from 475 to 514. I know something wrong with $key, so you right, but I wonder what is the problem of this string? Why $arr[491] never be equal to $key. I used echo $arr[491] and echo $key lines. And then they gave similar outputs. But indeed, they are not. I should find a way to examine their similarity?
- twigletmac
- Her Royal Site Adminness
- Posts: 5371
- Joined: Tue Apr 23, 2002 2:21 am
- Location: Essex, UK
String Parsing costs my last 3 or 4 hours
Finally i found the problem, following assignment is fatal
However I'm still thirsty to answer
The actual problem is stem from string parsing. Since our string includes <, ,",1,8 the normal string assignment does not work. Now the question is obvious, What is the all rules for escape charcters.(php manual is not a good guide on this issue)
Thanx All,
Code: Select all
$key="<marquee border="0" height="18"";The actual problem is stem from string parsing. Since our string includes <, ,",1,8 the normal string assignment does not work. Now the question is obvious, What is the all rules for escape charcters.(php manual is not a good guide on this issue)
Thanx All,