jzimmerlin Posted November 10, 2006 Share Posted November 10, 2006 Let's say I have a string that is... 01234567890abcd[ignorethis]blahblahblahIs there a method that can remove the stuff inside of the [ ]? Link to comment https://forums.phpfreaks.com/topic/26766-the-easiet-possible-way/ Share on other sites More sharing options...
haaglin Posted November 10, 2006 Share Posted November 10, 2006 Take a look at php's ereg() function. complicated, but will do the job. look at http://www.regular-expressions.info/tutorial.html for some idea of what it can do. Link to comment https://forums.phpfreaks.com/topic/26766-the-easiet-possible-way/#findComment-122374 Share on other sites More sharing options...
Caesar Posted November 10, 2006 Share Posted November 10, 2006 For future reference, take a look at http://www.php.net first. A little effort before asking questions is always appreciated.Now...I basically did it for you here:[code]<?php $string = '01234567890abcd[ignorethis]blahblahblah'; preg_match('/[a-z0-9]+(\[[a-z0-9]+\])[a-z0-9]+/',$string,$matches); $cleantxt = str_replace($matches[1],'',$matches); $ignoredtxt = $matches[1]; echo"$cleantxt[0]"; // 01234567890abcdblahblahblah?> [/code] Link to comment https://forums.phpfreaks.com/topic/26766-the-easiet-possible-way/#findComment-122381 Share on other sites More sharing options...
Nicklas Posted November 10, 2006 Share Posted November 10, 2006 [code=php:0]<?php$string = '01234567890abcd[ignorethis]blahblahblah';echo preg_replace('/\[.*]/', '', $string);?>[/code] Link to comment https://forums.phpfreaks.com/topic/26766-the-easiet-possible-way/#findComment-122382 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.