$newBlogInfo=new BlogInfo("好人一個", $owner, "that's all", null, $id = -1 );
// check if there already is a blog with the same mangled name while( $this->getBlogInfoByName( $blog->getMangledBlog() ) ) { $i++; // and if so, assign a new one (if we already tried with blogname+"i" we have to strip "i" before adding it again!) $newMangledName = ( ($i > 1) ? substr( $blog->getMangledBlog(), 0, strlen( $blog->getMangledBlog() )- strlen($i-1) ).$i : $blog->getMangledBlog().$i ); $blog->setMangledBlog( $newMangledName ); }