#native_company# #native_desc#


By Sean Baker
on August 9, 2006

Version: 1

Type: Function

Category: Other

License: GNU General Public License

Description: Retrieve & parse wedding registry information for a Bed, Bath, and Beyond online registry given the registry number. Fills an array with item description, price, UPC, # requested, and # purchased.

//  Registry-bbb.php 1.0 -- Goes out to the printable version of Bed, Bath, and Beyond's wedding registry website and retrieves all items awaiting purchase
//  Originally developed for a wedding website to allow something better than just linking to their website.
//  Fills an array with the structure $registry[] with ['desc'] = Description, ['UPC'] = UPC code / color, ['price'] = obvious, ['ask'] = quantity requested, ['have'] = quantity purchased
//  NOTE: You must define $regnum with your registry number
//  More releases will follow as we register other places.
//  Released under the GPL - do what you like with it, but don't blame me if it breaks something.  Sending this out because I wish I hadn't had to learn what little I actually know about regular expressions in order to code this.
//  Code is probably ugly as I've not coded anything in YEARS, so bear with the mistakes and send suggestions for improvements to:
//  [email protected].
//  Thanks, and enjoy

	$c = curl_init();
	curl_setopt($c, CURLOPT_URL, 'http://www.bedbathandbeyond.com/regGiftRegistry.asp?order_num=-1&WRN=-$regnum&st=D&smode=prt&show_images=Y&RNT=0&IPPREG=100&IPPREGPRT=100');
	curl_setopt($c, CURLOPT_RETURNTRANSFER, 1);
	$p = curl_exec($c);
	$p = addcslashes($p, "..37!@@177..377");


	foreach ($num[0] as $item) {
		$item = strip_tags($item);
		$item_tmp = explode('>',$item);
		$item_tmp = $item_tmp[1];

		switch ($j) {
			case 0:
			case 1:
				$item_tmp = preg_replace('(&nbsp;)',' ',$item_tmp);
				$registry[$k]['UPC'] = trim($item_tmp);
			case 2:
				$item_tmp = preg_replace('(&nbsp;)',' ',$item_tmp);
				$registry[$k]['price'] = trim($item_tmp);
			case 3:
				$registry[$k]['ask'] = $item_tmp;
			case 4:
				$registry[$k]['have'] = $item_tmp;