PHP - Moved: Ereg_replace Alternative
This topic has been moved to PHP Regex.
http://www.phpfreaks.com/forums/index.php?topic=307671.0 Similar TutorialsThis topic has been moved to PHP Regex. http://www.phpfreaks.com/forums/index.php?topic=347016.0 This topic has been moved to PHP Regex. http://www.phpfreaks.com/forums/index.php?topic=359592.0 This topic has been moved to MySQL Help. http://www.phpfreaks.com/forums/index.php?topic=326563.0 I had this code but now I need to change it to newer preg_replace function Can someone help me to do it please? Here is the code: $newString = ereg_replace("[[:alpha:]]+://[^<>[:space:]]+[[:alnum:]/]","<a href=\"\\0\" target=\"_blank\">\\0</a>", $originalString); Thanks in advance. I am interested in just this little snippet of code I am writing for a basic TCP socket server in PHP. Just basically goes along the lines of this: Code: [Select] <?php $value = ereg_replace("\n\t\r", "", trim($input)).chr(); It's actually regarding the chr() I know actually its nothing to do with the regular expression replace but what does it actually mean to PHP? I mean I am just using it as an output from a socket_read (as that's what $input is assigned to the value of), but what does the char(0) mean? I mean I seem to remember it being knowing the end of a line of data once the clients sent data into the stream PHP looks at chr(0) as the end of the line of data is that the right way of thinking about this logically? Any helps appreciated, trying to explain such a topic on my blog and I am confused about what to say about that one little bit, I know it's not really part of the regular expression but what does it actually do? Again massive thanks in advance for any replies, Jeremy. Hello all, I need to switch my code from ereg_replace to preg_match but I'm having trouble figuring out how to get the syntax right for this and keep the same functionality. $vendor_ID = ereg_replace("^\*","",$key); Any advice on how to maintain this functionality but use non-deprecated methods? $customer_contact_id = preg_replace("`", "", $customer_contact_id); Am I doing something wrong? Every page that used the eregi_function, I changed to have it utilize the preg_function (because I saw a Youtube video telling me to do so). Now, every variable I perform the above on acts as if it doesn't exist. This has totally destroyed my system. What do I need to do here to fix things? How to solve this error out PHP Deprecated: Function ereg_replace() is deprecated in using this code Code: [Select] $shoutcast_on_off =''; $scsuccs = ''; $listenlink = ''.$scdef.''; $scfp = fsockopen("$scip", $scport, &$errno, &$errstr, 30); if(!$scfp) { $scsuccs=1; } $page = ''; if($scsuccs!=1){ fputs($scfp,"GET /admin.cgi?pass=$scpass&mode=viewxml HTTP/1.0\r\nUser-Agent: SHOUTcast Song Status (Mozilla Compatible)\r\n\r\n"); while(!feof($scfp)) { $page .= fgets($scfp, 1000); } $loop = array("STREAMSTATUS"); $y=0; while($loop[$y]!=''){ $pageed = ereg_replace(".*<$loop[$y]>", "", $page); $scphp = strtolower($loop[$y]); $$scphp = ereg_replace("</$loop[$y]>.*", "", $pageed); $y++; } fclose($scfp); } $online1 = ''; if ($streamstatus == "1") { $online1 = '<center><img src="'.$BASEURL.'/styles/'.$theme.'/theme_images/DJ.png" border="0" height="150"></center><br> <center><a href="'.$BASEURL.':'.$scport.'/listen.pls"><img src="'.$BASEURL.'/styles/'.$theme.'/theme_images/klausom.png" width="150px" height="auto"></a></center>'; } else { $online2 = ''; $online2 = '<center><img src="'.$BASEURL.'/styles/'.$theme.'/theme_images/off.png" border="0" height="150"></center>'; } // BEGIN Plugin: shoutcast_on_off $shoutcast_on_off = $online1.$online2; // END Plugin: shoutcast_on_off eval("\$shoutcast = \"".$TSUE['TSUE_Template']->LoadTemplate('shoutcast')."\";"); return $shoutcast; Can anyone help me with this - I don't normally do coding.
I've just moved an old site onto new hosting and I'm getting this message: Deprecated: Function ereg_replace() is deprecated
The code looks like this:
if( preg_match( '/sl/i', $sOption ) )
$sContent = addslashes( $sContent );
else
$sContent = stripslashes( $sContent );
$sContent = ereg_replace( "\r", '', $sContent );
if( preg_match( '/len/i', $sOption ) )
$sContent = checkLengthOfTxt( $sContent );
I changed it to look like this:
if( preg_match( '/sl/i', $sOption ) )
$sContent = addslashes( $sContent );
else
$sContent = stripslashes( $sContent );
$sContent = preg_replace( "\r", '', $sContent );
if( preg_match( '/len/i', $sOption ) )
$sContent = checkLengthOfTxt( $sContent );
But now get this warning message:
Warning: preg_replace() [function.preg-replace]: Empty regular expression
I didn't build the site so I don't even know what the script is trying to do - forgive my ignorance!
Hi i learnt today hard way that die(); can kill of loading the rest of your html page if you place it in the middle of your html after a few hours of trying to work out what was wrong and wondered what alternatives there are i have tried a few like "E_USER_ERROR" and "trigger_error" but none halt the script and display a message or do it without loading the rest of my page, There must be another way i just havent found it and would be really grateful if someone could tell me it. Thanks, Blink359 So the server that host my website is not accepting .php files at the moment. I have a form mail in .php format, can anyone recommend an alternative form mail that will not use .php extension? Thank you kindly So to stop third-party traffic on certain media files my site does, I did a download.php type script that just took in the media id, and found the filename and did a readfile on it for the user. The problem is that when you start doing massive amounts of traffic with it, I think the readfile stream is taking up a lot of cpu. Is there any alternative to readfile that creates a direct link between the user and the file, instead of it having to go through the php? I'm afraid that this is something I need to do on the server end, and not in PHP, but I figured I'd ask. i need to read a pdf and convert it to raw text (with line breaks - but that's as fancy as i need it)... pdflib does way more than i need, and it's super expensive, and i don't really see the need to install an app on my server just to read a simple pdf... there must be an alternative out there, but i can't seem to find it... and when all of php.net seems to reference pdflib, i start to get a little discouraged... it seems like a simple pdf reader class/package would be open source somewhere... any suggestions? thanks I need to use something else than cURL to create the code to login to myspace accounts, I have to be able to enter postfields, Thanks I am running a script that uses curl to fetch an image and then pass it through to a user. It works well but is consuming a large amount of bandwidth. Is there another way that I could pass the url to the user directly, bypassing my host? Is there a way to do get_called_class for versions lower than php 5.3? Hey guys. I currently have my website set up 'generating' php pages, rather than simply getting data off the database. Which is silly. I have no rectified that issue but end up with ugly urls such as http://www.worldwidelighthouses.com/Lighthouses/English-Lighthouses/Trinity-House-Owned/Lighthouse.php?Lighthouses=Beachy-Head Whats the best way to translate that into http://www.worldwidelighthouses.com/Lighthouses/English-Lighthouses/Trinity-House-Owned/Beachy-Head Im hopeless with apaches mod_rewrite... Many many thanks in advance. Danny Hi all - I have a PHP form which allows users to submit data multiple times - in other words then can submit multiple records into the database using the same form over and over again. So currently how it works is once they've entered data and hit submit, the form refreshes and all fields get emptied, allowing the user to again enter more info. My client wants some sort of confirmation that data has been entered. I originally thought a simple pop-up/alert box saying 'Your data has been successfully entered' would do the trick since the user could then click 'ok', closing the pop-up to go about entering more data. However I hear a lot of disagreement on using javascript pop-ups due to pop-up blockers, javascript being turned off, etc. What alternatives exist to notify the user that their data has been submitted, while also allowing them to then continue entering more data? thanks! Steve I want to encode a long string, and wish to make it shorter. base64_encode is very handy but it makes the string length longer. Is there an alternative to do the encoding/decoding with shorter encoded string length? I want a free alternative to 000webhost. I don't want to use something like xampp because eugh I don't get on with it. Thanks |