Jump to content

Recommended Posts

hmm seems i have a problem with these php codes :

 

 

while ( // some expression 
{
$a .= $b.' && ';
}

$finala = substr($a,0,-4);


if ($finala == 3 )
{//do stuff
}


 

the if statement seems do not working,

i get some values from sql (which are int) .

 

put them after each other like you see in the code  :      2 && 5 && 4 &&...

then i remove the 4 letters from the end  which is    " && "  .

then check all of them if they are equal to something.

 

but the above code seems not working.

i put a echo there  ,and saw that substr is not working and won't remove .

i changed that line in while to :

 

$a .= '$b'.' && ';

 

but do not work either .

how can i solve it ?

(i guess maybe i'm comparing a string to int? )

 

 

Link to comment
https://forums.phpfreaks.com/topic/82776-string-code-on-php/
Share on other sites

oh i get it now :)

the first time it worked , not fine . just run the if statement , i was wondering about it . so it took the first character !

you mean i put the string in an array , then check the first key in the array ?

 

let me explain it more clear,

in mysql data base , in a column , i've got some numbers in some rows . like :

 

column

 

4

4

3

4

2

 

that while loop fetch this column records .  and put it on the $a you saw  ,

so for example in this case $a would be  :      4 && 4 && 3 && 4 && 2 && , then i remove the last 4 characters . it will be :

4 && 4 && 3 && 4 && 2

the i campre it to a value in if statement . for example  :

 

if (4 && 4 && 3 && 4 && 2 == 4 )

 

which it isn't .

so any better idea ? 

thanks for taking time

 

Link to comment
https://forums.phpfreaks.com/topic/82776-string-code-on-php/#findComment-421025
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.