Archive for March, 2008

Recursive str_replace in PHP

Thursday, March 20th, 2008

I was looking for a recursive str_replace in php tonight and I couldn’t find any, so I wrote one. This takes the exact same parameters as str_replace, in the same order. It recursively searches the $subject, replacing $search with $replace, while keeping track of how many times ($count) it has replaced the $subject.

<?
function str_replace_recursive($search,$replace,$subject,&$count=0){
	$newcount=$count;
	$subject = str_replace($search,$replace,$subject,$newcount);
	$count = $newcount+$count;
	if(!(strpos($subject,$search)===false)){
		return str_replace_recursive($search,$replace,$subject,$count);
	}else{
		return $subject;
	}
}
?>

Example:

$count=0;
$string = "; ; I; am; ; ; ; ; become; ; ; ; ; ; ; ; ;";
string = str_replace_recursive('; ;',';',$string,$count);

echo $string;
echo $count;

Outputs:
string --> I; am; become;
count --> 12

(Note that this is not the best code to use for this situation; can you write a faster solution to this example using only plain vanilla str_replace?)

Big survey update

Tuesday, March 18th, 2008

I’m rolling out a big survey update today that should simplify and improve the data that gets collected; as always, this will help with predictions. Expect this around 9:00pm Pacific on Tuesday; I’ll make another note here when the update gets “pushed” out.

Later this week, I’ll be clarifying the privacy policy and beefing up privacy safeguards.

By the way, it looks like MIT has been sending out rejection letters; let me know if you’ve seen any MIT acceptances.

Bug in Scriptaculous demo

Monday, March 17th, 2008

I’ve been updating the site to use Prototype.js, an Ajax framework. In the process, I was looking for some demo code. Scriptaculous, as they often do, came to the rescue. However, they have a bug on their page that deals with the Prototype Ajax.Updater. They say:

(more…)

Which schools are GPA-oriented?

Thursday, March 6th, 2008

Other bloggers have been discussing which schools place the most emphasis on GPA.

At Mychances.net, at least, it’s our experience that the schools at the “top” are the ones most likely to take into account more than GPA and scores. These are the ones most difficult to “chance” based on numbers alone. The ones in the middle of the pack tend to be pretty well predictable based on GPA, standardized tests, and little more than that.