Jump to content

Do you actually have to...


Neptunus Maris

Recommended Posts

Brothas and Sistas

 

Do you actually have to use the third parameter in preg_match_all???

 

 preg_match_all(string $pattern, string $subject, array &$matches [, int $flags [, int $offset]]) 

 

This is before I test, I rarely use the pregs...

 

So if you know please let me know..

 

Thanks,

Your Favorite Sea God Neptune...lol, kidding

Link to comment
https://forums.phpfreaks.com/topic/74824-do-you-actually-have-to/
Share on other sites

Yes you do.

 

Since the parameter is not in the [ ] it means it is a required parameter.

 

ok...but what if i just want to find each pattern find but dont need to print it? what would i do with the 3rd parameter then?

 

like this:

 

<?php
//--------
//	$pattern = "/^http://.*\.+/";

	$cleaned_str = eregi_replace($pattern, "[don't know yet]", $cleaned_str);

	//test to be contained inside the eregi_replace() function
	eregi_replace($pattern, "<a href = \"".preg_match_all($pattern, $cleaned_str, $matches)."\">".preg_match_all($pattern, $cleaned_str, $matches)."</a>", $cleaned_str);

//--------
?>

 

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.