rossh Posted November 2, 2006 Share Posted November 2, 2006 Hi i want to be able to remove everything after a question mark in a string. Can someone help me out.ThanksRoss Quote Link to comment Share on other sites More sharing options...
roopurt18 Posted November 2, 2006 Share Posted November 2, 2006 [code]<?php$string = 'Hello, World! How are you? It looks like you\'re fine!';$string = explode('?', $string);$string = $string[0];echo $string;?>Outputs:Hello, World! How are you?[/code] Quote Link to comment Share on other sites More sharing options...
ruano84 Posted November 2, 2006 Share Posted November 2, 2006 Hi,This is a way to do it:[code]<?php$chain="abcde?edcba";$chr_pos=strpos($chain,"?");$final_chain=substr($chain,0,$chr_pos);echo $chain;?>[/code]I Hope it could help you Quote Link to comment Share on other sites More sharing options...
Nicklas Posted November 2, 2006 Share Posted November 2, 2006 or slightly optimated[code]<?php$string = 'Hello, World! How are you? It looks like you\'re fine!';list($string) = explode('?', $string);echo $string;?>[/code] Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.