sKunKbad
Members-
Posts
1,832 -
Joined
-
Last visited
-
Days Won
3
Everything posted by sKunKbad
-
Btherl, thanks for the code example. I just got back from a fishing trip, and was surprised to see how far this thread has gone. From reading the thread posts I understand a little more about why classes and objects would be used.
-
I've read a couple of things about objects and classes, but I can't seem to understand why they are used. The explanations are bizarre. Does anyone have a sample of some code that shows 1) standard code, then 2) improved OOP code? Just curious to learn how this can help me.
-
I don't know nothing about PHP. I want to learn how.
sKunKbad replied to logged_with_bugmenot's topic in PHP Coding Help
For learning, you might try EasyPHP. It's free from sourceforge: http://sourceforge.net/projects/quickeasyphp Another way to learn php is to just buy the cheapest hosting plan/domain you can that has php enabled. IXwebhosting is pretty nice. Then just use your favorite text editor, like Notepad++, and your favorite ftp client, like FileZilla, pick up a good book like "Programming PHP" by O'rielly books, and your set. -
try this then: print "<p>session var: ";print ($_SESSION['is_admin']);print "<p>session var: <p>";
-
<?php session_start(); if (!isset($user_id)){ $_SESSION['is_admin']='rgraham45'; // you gotta actually declare something $user_id = $_SESSION['is_admin']; } else { $user_id = 'somePreviouslySetValue'; } print ("The current value of the session variable is {$_SESSION['is_admin']}<br />"); print ("See for yourself:<br />"); print_r($_SESSION['is_admin']); ?>
-
Just set the session cookie to expire later. The first argument to session_set_cookie_params is the number of seconds in the future (based on the server's current time) that the session will expire. So if you want your sessions to last 100 days: $expireTime = 60*60*24*100; // 100 days session_set_cookie_params($expireTime);
-
I did delete the cookie before retesting. I have the shopping cart cookie info set to expire in 7 days because that is how long the cart exists on the Amazon server unless modified. I have been using print_r, and the actual cookie array is there... so I guess it may not be the cookie, but because the script works fine in IE, but not firefox or opera, I was assuming that the problem had to be something related to client side.
-
I did make that change to session_name to include quotes, but it didn't fix my problem.
-
If I view my script Opera and Firefox, I am having some various problems that don't exist in IE6 or IE7, and I think they may be due to the way that Firefox and Opera handle cookies, but I'm not sure. If anyone can look at my script at tell me if there are some problems I'd appreciate it. BTW, php.ini is set for session.use_trans_sid=1. Thank you. This live testing page is at http://www.sewingcenter.tv/abc.php5?Action=Search <?php session_name(bookstoreID); session_set_cookie_params(604800); session_start(); ?> <?php define('KEYID','1KSDRC8DMVTJ0HEKBSG2'); define('AssocTag','temevallsewic-20'); if (isset($_SESSION['SessionCartId'])){ $CartId = $_SESSION['SessionCartId']; }else{ $CartId = ''; } if (isset($_SESSION['HMAC'])){ $HMAC = $_SESSION['HMAC']; }else{ $HMAC = ''; } if($_GET['Action'] == 'Search'){ print(" <div class='right-column'> <div class='greenbox-top'></div> <div class='greenbox-bg'> <form action='{$_SERVER['PHP_SELF']}' method='get'> <h2>Book Search</h2> <p style='margin-top:16px;' class='heavy'>Search For:</p> <div><input type='hidden' name='SearchIndex' value='Books' /></div> <p><input type='text' name='SearchString' size='24'/></p> <p style='margin-top:16px;' class='heavy'>Search By: <select name='SearchBy'> <option value='Title'>Title </option> <option value='Author'>Author</option> <option value='Keywords'>Keywords</option> </select></p> <div><input type='hidden' name='Action' value='Search' /></div> <div><input type='hidden' name='Page' value='1' /></div> <div><input type='hidden' name='NextPage' value='2' /></div> <p style='margin-top:16px'><input type='submit' value='Search!'/></p> </form> "); if($_SESSION['SessionCartId'] != ''){ $CartGet = "{$_SERVER['PHP_SELF']}?Action=CartGet"; print("<p class='heavy' style='text-align:center; margin-top:15px;'><img src='img/cart.gif' alt='shopping cart button'/> <a href='$CartGet'>View Cart</a></p>"); } print(" </div> <div class='greenbox-bottom'></div> "); print(" </div> <!-- Some stuff taken out here just to help reduce the amount of code you need to look at --> "); } ?> <?php if($_GET['Action'] == 'Search'){ if ($_GET['SearchString'] == ''){ print(" <h2>Search Now!</h2> "); } else{ $SearchString = urlencode($_GET['SearchString']); ItemSearch($_GET['SearchIndex'], $SearchString, $_GET['SearchBy'], $_GET['Page'], $_GET['NextPage']); } } if($_GET['Action'] == 'SeeDetails'){ ItemLookup($_GET['ASIN'], $_GET['SearchIndex']); } if($_GET['Action'] == 'CartAdd'){ if(!isset($_SESSION['OfferListingId']['0'])){ getCartContents(); }else{ if($CartId != ''){ CartAdd(); }else{ CartCreate(); } } } if($_GET['Action'] == 'Remove'){ removeFromCart($_GET['CartItemId']); } if($_GET['Action'] == 'CartGet'){ getCartContents(); } if($_GET['Action'] == 'AddChoice'){ if(!isset($_SESSION['OfferListingId'])){ getCartContents(); }else{ $Choice = $_GET['Choice']; $_SESSION['OfferListingId']['0'] = $_SESSION['OfferListingId']["$Choice"]; if($CartId != ''){ CartAdd(); }else{ CartCreate(); } } } ?> <?php function ItemSearch($SearchIndex, $SearchString, $SearchBy, $Page, $NextPage){ $request="http://ecs.amazonaws.com/onca/xml?Service=AWSECommerceService"; $request.="&AWSAccessKeyId=".KEYID."&AssociateTag=".AssocTag."&ItemSearch.Shared.Version=2006-09-11"; $request.="&Operation=ItemSearch&ItemSearch.Shared.ResponseGroup=Medium,Offers"; $request.="&ItemSearch.Shared.SearchIndex=$SearchIndex"; $request.="&ItemSearch.Shared.$SearchBy=$SearchString"; $request.="&ItemSearch.1.ItemPage=$Page"; $request.="&ItemSearch.2.ItemPage=$NextPage"; $session = curl_init($request); curl_setopt($session, CURLOPT_HEADER, false); curl_setopt($session, CURLOPT_RETURNTRANSFER, true); $response = curl_exec($session); curl_close($session); $parsed_xml = simplexml_load_string($response); printSearchResults($parsed_xml, $SearchIndex); } //------------------------------------------------------------------------------------------------------ function printSearchResults($parsed_xml, $SearchIndex){ unset($_SESSION['OfferListingId']); $numOfItems = $parsed_xml->Items->TotalResults; $totalPages = $parsed_xml->Items->TotalPages; print("<h2>Your Search Results</h2>"); print("<div style='width:438px;'>\n"); if($numOfItems>0){ $Choice = 0; foreach($parsed_xml->Items as $Items){ foreach($Items->Item as $current){ if(isset($current->Offers->Offer->OfferListing->OfferListingId)){ //only show items for which there is an offer print("\t\t\t<div style='width:438px; float:left; padding-bottom:15px; padding-top:15px; border-bottom: solid red 2px;'><img style='margin-left:40px; clear:both;' src='".$current->SmallImage->URL."' alt='small cover image' />\n"); print("\t\t\t<p style='font-weight:bold;'>".utf8_decode(str_replace("&", "&", $current->ItemAttributes->Title))."</p>\n"); print("\t\t\t<p>Author: ".utf8_decode($current->ItemAttributes->Author)."</p>\n"); print("\t\t\t<p>Price: ".$current->Offers->Offer->OfferListing->Price->FormattedPrice."</p>\n"); $asin = $current->ASIN; $details = "{$_SERVER['PHP_SELF']}?Action=SeeDetails&ASIN=$asin&SearchIndex=$SearchIndex"; print("\t\t\t<p style='margin-left:40px;'><a href='$details'>See Details</a></p>\n"); $_SESSION['OfferListingId'][] = (string)$current->Offers->Offer->OfferListing->OfferListingId; $CartAdd = "{$_SERVER['PHP_SELF']}?Action=AddChoice&Choice=$Choice"; print("\t\t\t<p style='margin-left:40px;'><a href='$CartAdd'>Add to Cart</a></p>\n"); print("\t\t</div>\n\n"); $Choice++; } } } }else{ print("<center>No matches found.</center>"); } print("</div>"); print("<div style='float:left; width:100%; margin-top:25px; margin-bottom:20px;'>"); if($_GET['Page'] > 1 && $totalPages > 2){ $SearchString = urlencode($_GET['SearchString']); $SearchBy = $_GET['SearchBy']; $Page = $_GET['Page']-2; $NextPage = $Page +1; $prevPage = "{$_SERVER['PHP_SELF']}?Action=Search&SearchIndex=$SearchIndex&SearchBy=$SearchBy&SearchString=$SearchString&Page=$Page&NextPage=$NextPage"; print("<div style='float:left; width:50%; text-align:right'><p><a href='$prevPage'>Previous Page</a></p></div>"); } if($_GET['NextPage'] < $totalPages){ $SearchString = urlencode($_GET['SearchString']); $SearchBy = $_GET['SearchBy']; $Page = $_GET['Page']+2; $NextPage = $Page +1; $nextPageSet = "{$_SERVER['PHP_SELF']}?Action=Search&SearchIndex=$SearchIndex&SearchBy=$SearchBy&SearchString=$SearchString&Page=$Page&NextPage=$NextPage"; print("<div style='float:left; width:45%; padding-left:5%;'><p><a href='$nextPageSet'>Next Page</a></p></div>"); } print("</div>"); } //------------------------------------------------------------------------------------------------------- function ItemLookup($asin, $SearchIndex){ $request = "http://ecs.amazonaws.com/onca/xml?Service=AWSECommerceService&AWSAccessKeyId=".KEYID."&AssociateTag=".AssocTag."&Version=2006-09-11&Operation=ItemLookup&ItemId=$asin&ResponseGroup=Medium,Offers"; $session = curl_init($request); curl_setopt($session, CURLOPT_HEADER, false); curl_setopt($session, CURLOPT_RETURNTRANSFER, true); $response = curl_exec($session); curl_close($session); $parsed_xml = simplexml_load_string($response); printDetails($parsed_xml, $SearchIndex); } //------------------------------------------------------------------------------------------------------- function printDetails($parsed_xml, $SearchIndex){ print("<div id='details'>\n"); print("\t\t\t<div style='position:relative; float:right; width:25%; margin-top:20px;'>\n\t\t\t\t<img src='".$parsed_xml->Items->Item->MediumImage->URL."' alt='medium cover image' />\n\t\t\t</div>\n"); print("\t\t\t<div style='position:relative; float:left; width:70%; margin-top:20px;'>\n\t\t\t\t<p style='font-weight:bold;'>".utf8_decode(str_replace("&", "&", $parsed_xml->Items->Item->ItemAttributes->Title))."</p>\n"); print("\t\t\t\t<p>Author: ".utf8_decode($parsed_xml->Items->Item->ItemAttributes->Author)."</p>\n"); print("\t\t\t\t<p>".$parsed_xml->Items->Item->ItemAttributes->Binding."</p>\n"); print("\t\t\t\t<p>".$parsed_xml->Items->Item->ItemAttributes->NumberOfPages." pages</p>\n"); if ($parsed_xml->Items->Item->EditorialReviews->EditorialReview->Content != ''){ print("\t\t\t\t<p style='border:dashed green 3px; padding:10px; margin:10px 0px 10px 0px;'>".utf8_decode(str_replace("<br>", "<br />", strip_tags($parsed_xml->Items->Item->EditorialReviews->EditorialReview->Content, '<br><i><b><strong><em>')))."</p>\n"); } print("\t\t\t\t<p style='font-weight:bold;'>".$parsed_xml->Items->Item->Offers->Offer->OfferListing->Price->FormattedPrice."</p>\n"); $_SESSION['OfferListingId']['0'] = (string)$parsed_xml->Items->Item->Offers->Offer->OfferListing->OfferListingId; $CartAdd = "{$_SERVER['PHP_SELF']}?Action=CartAdd"; print("\t\t\t\t<p style='font-weight:bold;'><a href='$CartAdd'>Add to Cart</a></p>\n"); $search = "{$_SERVER['PHP_SELF']}?Action=Search"; print("\t\t\t\t<p style='font-weight:bold;'><a href='$search'>Continue Searching</a></p></div>\n"); print("\t\t\t</div>\n"); print("\t\t\t<div class='bloodline'>\n\t\t</div>\n"); } //------------------------------------------------------------------------------------------------------- function cartCreate(){ if (isset($_SESSION['HMAC'])){ //this could have checked for the SessionCartId and the result would have been the same getCartContents(); }else{ $request="http://ecs.amazonaws.com/onca/xml?Service=AWSECommerceService&AWSAccessKeyId=".KEYID."&AssociateTag=".AssocTag."&Version=2006-09-11&Operation=CartCreate&Item.1.OfferListingId=".$_SESSION['OfferListingId']['0']."&Item.1.Quantity=1"; $session = curl_init($request); curl_setopt($session, CURLOPT_HEADER, false); curl_setopt($session, CURLOPT_RETURNTRANSFER, true); $response = curl_exec($session); curl_close($session); $parsed_xml = simplexml_load_string($response); $_SESSION['SessionCartId'] = (string)$parsed_xml->Cart->CartId; $preHMAC = (string)$parsed_xml->Cart->URLEncodedHMAC; $_SESSION['HMAC'] = str_replace("+", "%2b", $preHMAC); showCartContents($parsed_xml); } } //------------------------------------------------------------------------------------------------------- function cartAdd(){ $CartId = $_SESSION['SessionCartId']; $HMAC = $_SESSION['HMAC']; $request="http://ecs.amazonaws.com/onca/xml?Service=AWSECommerceService&AWSAccessKeyId=".KEYID."&AssociateTag=".AssocTag."&Version=2006-09-11&Operation=CartAdd&CartId=$CartId&HMAC=$HMAC&Item.1.OfferListingId=".$_SESSION['OfferListingId']['0']."&Item.1.Quantity=1"; $session = curl_init($request); curl_setopt($session, CURLOPT_HEADER, false); curl_setopt($session, CURLOPT_RETURNTRANSFER, true); $response = curl_exec($session); curl_close($session); $parsed_xml = simplexml_load_string($response); showCartContents($parsed_xml); } //------------------------------------------------------------------------------------------------------- function showCartContents($parsed_xml){ print("<h2>Shopping Cart</h2>\n"); unset($_SESSION['OfferListingId']); $color1 = "#FFFF80"; $color2 = "#FFEF66"; $row_count = 0; $isCartEmpty = 0; foreach($parsed_xml->Cart->CartItems->CartItem as $current){ $row_color = ($row_count % 2) ? $color1 : $color2; $CartItemId = $current->CartItemId; $remove="{$_SERVER['PHP_SELF']}?Action=Remove&CartItemId=$CartItemId"; print("<div style='position:relative; float:left; padding:10px; background-color:$row_color; width:667px; height:100%; font-weight:bold;'>\n\t<div style='float:left; width:449px;'>\n\t\t<p>".utf8_decode(str_replace("&", "&", $current->Title)).": </p>\n\t</div>\n\t<div style='float:left; width:66px;'>\n\t\t<p>".$current->Price->FormattedPrice."</p>\n\t</div>\n\t<div style='float:left; width:132px;'>\n\t\t<p style='padding:0;'><a href='$remove'>(Remove from Cart)</a></p>\n\t</div>\n</div>\n"); $row_count++; $isCartEmpty++; } if($isCartEmpty == 0){ print("<p style='color:red;'>Your Shopping Cart Is Now Empty.</p>\n"); } if($isCartEmpty != 0){ print("<div style='float:left; clear:left; width:100%; margin-top:10px; font-weight:bold;'>\n\t<p>Subtotal: ".$parsed_xml->Cart->CartItems->SubTotal->FormattedPrice."</p>\n</div>\n"); } $continue = "{$_SERVER['PHP_SELF']}?Action=Search"; print("<div style='float:left; clear:left; width:100%; font-weight:bold;'>\n\t<p><a href='$continue'>Continue Shopping</a></p>\n</div>\n"); if($isCartEmpty != 0){ $checkout=$parsed_xml->Cart->PurchaseURL; print("<div style='float:left; clear:left; width:100%; font-weight:bold;'>\n\t<p><a href='$checkout'>Checkout Now</a></p>\n</div>\n"); } } //------------------------------------------------------------------------------------------------------ function removeFromCart($CartItemId){ $CartItemId = $_GET['CartItemId']; $request = "http://ecs.amazonaws.com/onca/xml?Service=AWSECommerceService&AWSAccessKeyId=".KEYID."&AssociateTag=".AssocTag."&Version=2006-09-11&Operation=CartModify&CartId=".$_SESSION['SessionCartId']."&HMAC=".$_SESSION['HMAC']."&Item.1.CartItemId=$CartItemId&Item.1.Quantity=0"; $session = curl_init($request); curl_setopt($session, CURLOPT_HEADER, false); curl_setopt($session, CURLOPT_RETURNTRANSFER, true); $response = curl_exec($session); curl_close($session); $parsed_xml = simplexml_load_string($response); showCartContents($parsed_xml); } //----------------------------------------------------------------------------------------------------- function getCartContents(){ $request = "http://ecs.amazonaws.com/onca/xml?Service=AWSECommerceService&AWSAccessKeyId=".KEYID."&AssociateTag=".AssocTag."&Version=2006-09-11&Operation=CartGet&CartId=".$_SESSION['SessionCartId']."&HMAC=".$_SESSION['HMAC']; $session = curl_init($request); curl_setopt($session, CURLOPT_HEADER, false); curl_setopt($session, CURLOPT_RETURNTRANSFER, true); $response = curl_exec($session); curl_close($session); $parsed_xml = simplexml_load_string($response); showCartContents($parsed_xml); } ?>
-
neither of those worked, but actually, i dont want to unset them, i want to completely delete them, so I was thinking something like this would work: array_splice($_SESSION['OfferListingId'],0); but it doesn't. I don't know what the heck is going on!
-
//I have a session array : $_SESSION['OfferListingId'][0]='bob'; $_SESSION['OfferListingId'][2]='ted'; $_SESSION['OfferListingId'][3]='mary'; $_SESSION['OfferListingId'][4]='jill'; $_SESSION['OfferListingId'][5]='spike'; //and when I try to unset the entire array using: unset($_SESSION['OfferListingId']); //it doesn't work. Why not?
-
Is there any difference in the speed of a program that has session.use_trans_sid set to 1 compared to 0. I would like to use it set to 1 in case anyone doesnt have cookies turned on, but not at the expense of slow loading pages. My connection speed is much to fast to tell either way, as I am on a 5 down 2 up connection. Anyone know?
-
well, i just like to test in as many browsers as i can
-
yeah, i was just being an idiot. it worketh.
-
NOT WORKING <a href="trytoinclude.php?OldPage=1">Index w/ Static text#1</a> <h1>Old Content</h1> <?php $pageNum = $_GET['OldPage']; // in this case OldPage = 1 print('<div>'); include('staticdoc'.$pageNum.'.txt'); print('</div>'); ?> PLEASE HELP
-
My site, which has basic session cookies, works in all browsers except Opera (My version for testing is v9.10). Is there some known problem with Opera and cookies? I've tried looking around the web, and searching here, but haven't found anything.
-
OK, yes I forgot the semicolon, and also the underscore in $SESSION. I fixed those two things, and the script works as intended. Thanks!
-
I need help with reassigning the value of $_SESSION['OfferListingId'][0], but what I have so far isn't working. $Choice = $_GET['Choice'] $_SESSION['OfferListingId'][0] = $SESSION['OfferListingId']["$Choice"]; // line 106 Parse error: syntax error, unexpected T_VARIABLE in /home/content/mysite/html/abc.php5 on line 106 Please help!
-
So, if cookies are turned off, the session will never work?
-
I have a script on a godaddy server, and it uses a session, and works fine unless I turn cookies off. Maybe I am wrong, but in theory, I thought that if I turned off cookies in the browser I am testing with, that php would automatically use some other way to store the session information. Unfortunately, when I turn cookies off in the browser, the script does not continue to work. I checked the phpinfo(), and the session.save_path is set to /tmp. I tried adding session_save_path("/home/content/a/b/c/abc/html/tmp"); before my call for the session to start, but it doesn't help. Am I wrong about sessions working if cookies are turned off?
-
Checking a string for all values of an array
sKunKbad replied to sKunKbad's topic in PHP Coding Help
I guess I should have been more specific. What I am looking for is a true or false value if ALL of the values in the $KeywordArray are in the string, and the matching of values should be case insensitive. For instance, if the $KeywordArray = (one, two, Three, Four, FIVE) and the string = "one two three four five six seven eight" then I'd want to have a value of true Right now I have: foreach ($KeywordArray as $verified){ if(eregi($verified,$TheString)){ print ("The String contains ALL your keywords"); } } However, right now the "the string contains all your keywords" will print if only one of the $KeywordArray values is in the string. -
If I have an array named $KeywordsArray, and I need to see if all of the values in the array are in a string named $TheString, what is the most efficient way to do this?
-
OK, now i understand the code I have so far, thanks to this site and php.net, and I'm working on this new code which is trying to only include certain elements that are in the $listArr array, but it doesn't work... <?php $parser=xml_parser_create(); function start($parser,$element_name,$element_attrs) { switch(strtolower($element_name)) { case "note": echo "\t<div style=\"color:red;background-color:yellow;\">\n\t\tRED TEXT"; break; case "to": echo "\n\t</div>\n\t<div style=\"color:green;\">\n\t\tTo: "; break; case "from": echo "\n\t</div>\n\t<div style=\"color:blue;\">\n\t\tFrom: "; break; case "heading": echo "\n\t</div>\n\t<div style=\"color:purple;\">\n\t\tHeading: "; break; case "body": echo "\n\t</div>\n\t<div style=\"color:orange; background-color:black;\">\n\t\tMessage: "; } } function stop($parser,$element_name) { echo ""; } function char($parser,$content) { echo trim($content); } xml_set_element_handler($parser,"start","stop"); xml_set_character_data_handler($parser,"char"); $fp=fopen("test.xml","r"); $listArr = array("to", "from", "heading", "body"); $content = ""; while ($data=fread($fp,4096)) { foreach ($listArr as $split) { while (eregi($split, $data)) { list($before, $after) = spliti("<".$split.">", $data, 2); list($content, $after) = spliti("</".$split.">", $after, 2); $data = $before . $after; $content++ } } xml_parse($parser,$data,feof($fp)) or die (sprintf("XML Error: %s at line %d", xml_error_string(xml_get_error_code($parser)), xml_get_current_line_number($parser))); } xml_parser_free($parser); ?> I know you gave me the advice on using something like this: $data = str_replace("</body>", "</body>\n<newelement>datajhere</newelement>", $data); But I'm not trying to replace anything am I... heck I dont know!!
-
For now, I need to try to understand the foreach construct, and list array functions in the while loop. I really want to understand and not just be a copy and paster! So, until then, I guess I'll be studying. Thanks for your help frost110!
-
Well, you certainly seem to whip out the code like you know it well. Is this just a hobby for you, or part of your job? I was wondering tonight about something. You have shown me how to remove elements from the output. What if the opposite was required? How would you create an array and impliment outputting only the elements in the array? Tonight I worked on adding style to the output. I don't know if this would ever help anybody else learn what I'm trying to learn, but here is what I got so far: the xml in a file called test.xml: <?xml version="1.0" encoding="ISO-8859-1"?> <note> <to>Tove</to> <target>no print</target> <from>Jani</from> <turkey> <heading>Reminder</heading> </turkey> <chicken> <heading>Chicken Reminder</heading> </chicken> <body>Don't forget me this weekend!</body> <to>Tove</to> <from>Jani</from> <heading>Reminder</heading> <body>Don't forget me this weekend!</body> <whatever>yes</whatever> </note> The parser with some style applied: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en"> <head> <title>Title</title> <style type="text/css"> #parsewrap {margin:0px auto; border: solid red 2px; width:500px;} </style> </head> <body> <?php echo "<div id=\"parsewrap\" style=\"text-align:center;\">"; $parser=xml_parser_create(); function start($parser,$element_name,$element_attrs) { switch(strtolower($element_name)) { case "note": echo "<div style=\"color:red;background-color:yellow;\">RED TEXT"; break; case "to": echo "</div><div style=\"color:green;\">To:"; break; case "from": echo "</div><div style=\"color:blue;\">From: "; break; case "heading": echo "</div><div style=\"color:purple;\">Heading: "; break; case "body": echo "</div><div style=\"color:orange; background-color:black;\">Message: "; } } function stop($parser,$element_name) { echo ""; } function char($parser,$data) { echo $data; } xml_set_element_handler($parser,"start","stop"); xml_set_character_data_handler($parser,"char"); $fp=fopen("test.xml","r"); $listArr = array("target", "whatever", "hork", "tacos", "chicken"); while ($data=fread($fp,4096)) { foreach ($listArr as $split) { while (eregi($split, $data)) { list($before, $after) = spliti("<".$split.">", $data, 2); list(, $after) = spliti("</".$split.">", $after, 2); $data = $before . $after; } } xml_parse($parser,$data,feof($fp)) or die (sprintf("XML Error: %s at line %d", xml_error_string(xml_get_error_code($parser)), xml_get_current_line_number($parser))); } xml_parser_free($parser); ?> </div> </div> </body> </html>