-
Posts
1,074 -
Joined
-
Last visited
Everything posted by EchoFool
-
works a treat! Thankyou !
-
Thanks MadTechie. The if statement doesn't seem to come out as true though anymore: <?php $Message = $row['Message']; //hiiide quote if (preg_match('%(.*\b\[/quote\])(.*)%si', $Message, $regs)) { { $Var1 = $regs[1]; // "[ quote] [ quote] test [/quote] why are you testing[/quote]" $Var2 = $regs[2]; // " because i want to!" } }Else{ Echo 'failed'; } The failed is being echo'd. Why could that be?
-
Thankyou for your response. It works a treat! Although to cover all eventualities of a forum post.... it is very common for a message to contain: <?php $Message = $MainMessage = '[ quote] [ quote] test [/quote] why are you testing[/quote] because i want to!'; ?> They may even have more quotes than that. And so at this stage it wouldn't split the message correctly as i just tried it, it cuts the first end quote then nothing after that. Though I still require it to cut into two $vars only no matter how many [ /quote ] tags are invovled. It should end up like: <?php $message[0] = '[ quote] [ quote] test [/quote] why are you testing[/quote]' // the quotes $message[1] = 'because i want to!' // the post Any ideas? Thanks for your response.
-
I am getting an offset error with my string, and am unsure on how to fix it as i don't totally know what is wrong in the first place..... this is what i have: <?php $MainMessage = '[quote] Hey there![/quote] Hello world!'; //hiiide quote $message = explode('[/quote]', $MainMessage); $quote_times = count($message) - 1; for($m=0;$m<$quote_times - 1;$m++){ $lastpart .= $message[$m].'[/quote]'; } $message[0] = $lastpart.$message[$quote_times - 1].'[/quote]'; $message[1] = $message[$quote_times]; ?> The error: The "real outcome" should be that: $message[0] = '[quote] Hey there![/quote]' $message[1] = 'Hello world!' Not sure why the lastpart variable is not being set? I do also have a question, will this script cause an error when ever the $MainMessage has no [ quote] tags. And also will it double crash if there was a message like: $MainMessage = '[quote] [quote] test [/quote] why are you testing[/quote] because i want to!'; Would this still result as: $message[0] = '[quote] [quote] test [/quote] why are you testing[/quote]' $message[1] = 'because i want to!' Or it will crash it due to more than one tag? I have yet to get it working at all but need to know If i am on the right lines?
-
Bump
-
Close to that but the two variables should be become like this: $Var1 = $regs[1]; // [24]Test[25] Thank you for reading![/quote] $Var2 = $regs[2]; // Response 14455. So everything before the last char of " " which is the ] is in one var... and everything after the ] goes to the second var. The original string is: [24]Test[25]Thank you for reading![/quote] Response 14455.
-
Replace? I'm not trying to convert or replace anything how ever...im not sure if i have misunderstood you, or you have misunderstood me lol. Just to sure, let me simplify it with a simple example say a string has: Hello there! And i wanted to "cut" this string so it become: $Var1 = Hello $Var2 = there! Only for my real situation i need to cut the string "after" the last char of : [/ QUOTE] So "everything" after the ] char from [/ QUOTE] Will go to $Var2 and everything before the ] include the ] itself goes to $Var1. If i were to replace it I would loose tags. The tags need to remain otherwise when echo'd for later use it won't process in the BBCode.
-
Yeh the tags will be the same every time. I just need to split that paragraph into two variables. Rather than one.
-
No no. Just to break the string apart From the the first char to the last char of Then to the end of the string.
-
I am getting lost on how to "extract" part of a variable's string leaving only what needs to be seen. I tried using explode function but that was not allowing it to save the tags around the text with it. This is the paragraph im processing: [24]Test[25]Thank you for reading![/quote] Response 14455. Now this whole paragraph above is in a variable as $Message But i want to forward the message but to stop the user "editing" what is being quoted i want to some how extract the quote. So from [24] to [/ QUOTE] it needs to take. So it then assigns it to a new variable so the new variable will become: [24]Testing[25]Thank you for reading![/quote] Leaving only for the main variable: Response 14455. Can php do this? I know how to explode a string but explodes don't take the symbol that separates the information. I need this to also take the tags with it.
-
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> I have this at top of my page if that is what you mean ?
-
For some unknown reason, when I echo a £ symbol related to money it comes out like this: Its a simple echo '£'.$Money; What causes this sort of thing, I have no idea where to begin to look with fixing this problem ???
-
Thank you for your replies guys! I will give your suggestion a try Ken. Thank you.
-
I have two time stamps one from a database and one which is "now". I was wondering if there was a way to compare the two to find out if the gap between them is greater than 20 minutes. These are the two fields <?php $Date = $row['SkipDate']; // from database $Date2 = date("Y-m-d H:i:s",time()); // now time ?> Is it a possible thing to do ?
-
If there is an automated script which creates an array but there is no parametres that match to create this "array" is there a way to check that the array is in simple words... blank? Because at the moment after my while loop which creates the array i have: $_SESSION['MissionID'] = $a[0]; But if the array wasn't greated because all the rows have been used which can happen then obviously $a[0]; won't exist. So i end up with: Notice: Undefined offset: 0 in C:\xampp\htdocs\test.php on line 6431 So was wondering if there was a way to "check" if the array is blank and if it is then skip it. I tried this: <?php If($a[0]>0){ // do it }Else { // do not } Didn't work though. Any suggestions? But that didn't work.
-
Oh i see. So array's start at [ 0 ] not [1] that would explain why I couldn't grab the value! Thanks Ken. wildteen88 - is array_Shift similar to my shuffle function?
-
I see so that produces: Array ( [0] => 25 ) Is there a way to extract the 25 to process with that ID?
-
Changed : $ID = $row['ID']; $a[] = $ID; to $a[] = $row['ID']; Though when i shuffle($a); Then Echo $a; I get "Array" as the response rather than the id. Why could that be?
-
Argh i fixed my error. Thank you!
-
Sure here it is: <?php $Find = mysql_query("SELECT ID FROM users") Or die(mysql_error()); If(mysql_num_rows($Find)>0){ $a = array(); While($row = mysql_fetch_assoc($Find)){ $ID = $row['ID']; $a[] = $ID; // this is where the error is } shuffle($a); $_SESSION['MissionID'] = $a; } ?> Thank you for replying
-
Oh i see thankyou for pointing me in the right direction. With your suggestion Ken, i produce this error: Fatal error: Cannot use [] for reading in C:\xampp\htdocs\missioninclude.php on line 426 Which relates to $a[] = $row['ID'];.
-
Not sure if i understand this correctly but im getting an error to do with my array syntax.... the idea is it creates a list of id's then picks one at random, but i cannot get it to work... any help is much appreciated. Parse error: syntax error, unexpected '[', expecting ')' in C:\xampp\htdocs\name.php on line 427 Im unsure on what i have done wrong. This is what i got: <?php $SELECT = mysql_query("SELECT ID FROM users") Or die(mysql_error()); $a = 0; While($row = mysql_fetch_assoc($Find)){ $ID = $row['ID']; Array ( [$a] => $ID; ) $a = $a + 1; } shuffle($a); $_SESSION['MissionID'] = $a; ?>
-
The output which has <div class etc Won't be detected as CSS or HTML because of the functions before it... so itll always come out as a block of chars and nothing else. So if i put [Q] to html ... the html will just come out as just chars .like it is already right? I can't get my head around this properly =/
-
I do have that.. if a user puts [Q] it converts to : <div class='quotetop'>QUOTE <span class=PositiveMoney> </span></div><div class='quotemain'><span class=NegativeMoney><?=$Message?> And [/Q] converts to: </span></div> But as you can see from above it won't allow it through.. unless im misunderstanding what you mean ?
-
Bump, any thoughts?