Source for file graphnew.php

Documentation is available at graphnew.php

  1. <?php
  2.  
  3. /*
  4. Program E
  5. Copyright 2002, Paul Rydell
  6. This file is part of Program E.
  7. Program E is free software; you can redistribute it and/or modify
  8. it under the terms of the GNU General Public License as published by
  9. the Free Software Foundation; either version 2 of the License, or
  10. (at your option) any later version.
  11.  
  12. Program E is distributed in the hope that it will be useful,
  13. but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. GNU General Public License for more details.
  16.  
  17. You should have received a copy of the GNU General Public License
  18. along with Program E; if not, write to the Free Software
  19. Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  20. */
  21.  
  22. /*
  23. SPEED IMPROVEMENTS.
  24. change logging to better understand what it is doing. then it will be easier to see where it is wasting time
  25. */
  26.  
  27. /**
  28. * GraphMaster
  29. *
  30. * Contains the AIML matching functions for Program E
  31. * @author Paul Rydell
  32. * @copyright 2002
  33. * @version 0.0.8
  34. * @package Interpreter
  35. * @subpackage Engine
  36. */
  37.  
  38. /**
  39. * The debugger function
  40. *
  41. * When uncommented, it will print the messages several functions will call.
  42. *
  43. * @todo the entire debug mechanism should be overhauled, this simple one line function doesn't cut it. Perhaps make use of several levels, function names and or timing to spefiy which part to debug.
  44. *
  45. * @param string $msg The message to be printed in debugger mode
  46. * @param integer $val no idea what this does, it's used in every function call but not in the function itself
  47. *
  48. * @return void Prints to HTML.
  49. */
  50. function debugger($msg,$val)
  51. {
  52. #print "$msg\n";
  53. }
  54.  
  55. /**
  56. * Get the template for the input, that, and topic
  57. *
  58. * Get the template for a paticular pattern and dialogue situation. If the pattern, including topic and that, was found in the cache, the mathcing routine is circumvented and that template used. This saves time.
  59. *
  60. * @todo The name gettemplate() and {@link findtemplate()} are too similar.
  61. *
  62. * @uses debugger()
  63. * @uses checkcache()
  64. * @uses graphwalker()
  65. * @uses findtemplate()
  66. * @uses fillcache()
  67. *
  68. * @global integer the Bot's ID.
  69. *
  70. * @param string $input The user's input
  71. * @param string $that The bot's previous output
  72. * @param string $topic The contents of the AIML tag <topic>
  73. * @param array &$inputstarvals contains the contents of the *'s when they are part of the matching pattern input string
  74. * @param array &$thatstarvals contains the contents of the *'s when they are part of the matching pattern that string
  75. * @param array &$topicstarvals contains the contents of the *'s when they are part of the matching pattern topic string
  76. * @param array &$patternmatched contains all patterns that were found. An input can have more than one sentence which are processed seperately.
  77. * @param array &$inputmatched contains all the individual sentences of a user's input.
  78. *
  79. * @return string The template belonging to the matching pattern.
  80. */
  81. function gettemplate($input,$that,$topic,&$inputstarvals,&$thatstarvals,&$topicstarvals,&$patternmatched,&$inputmatched)
  82. {
  83. global $selectbot;
  84.  
  85. // Put the input, that, and topic together into a single sentence to find a match for
  86. $combined = "<input> " . trim($input) . " <that> " . trim($that) . " <topic> " . trim($topic);
  87. debugger("Combined: $combined",2);
  88.  
  89. if (CACHE_CONTROL == 1 && checkcache($combined,$template,$inputstarvals,$thatstarvals,$topicstarvals,$patternmatched,$inputmatched)) {
  90. debugger("<BR><b>HIT CACHE!</b><br>",2);
  91. return $template;
  92. }
  93. else {
  94.  
  95. $inputmatched=array(trim($input)," : ",trim($that)," : ",trim($topic));
  96. // These arrays will hold the words that matched the wildcards in the pattern
  97. $inputstarvals=array();
  98. $thatstarvals=array();
  99. $topicstarvals=array();
  100.  
  101. $patternmatched=array();
  102.  
  103. // Get the template with graphwalker function.
  104. $mytemplateid=graphwalker($combined, -$selectbot , 1, 0, "", $inputstarvals, $thatstarvals, $topicstarvals, $patternmatched);
  105.  
  106. $mytemplate=findtemplate($mytemplateid);
  107.  
  108. $s_patternmatched="";
  109. $s_inputmatched="";
  110.  
  111. foreach ($patternmatched as $value) $s_patternmatched .= " " . $value;
  112. foreach ($inputmatched as $value) $s_inputmatched .= $value;
  113.  
  114. $patternmatched = $s_patternmatched;
  115. $inputmatched = $s_inputmatched;
  116.  
  117. if (CACHE_CONTROL == 1) {
  118. fillcache($combined, $mytemplateid, $inputstarvals, $thatstarvals, $topicstarvals, $patternmatched, $inputmatched);
  119. }
  120.  
  121. return $mytemplate;
  122. }
  123. }
  124.  
  125. /**
  126. * The graphwalker function finds the pattern that matches the combined input of input, that, and topic.
  127. *
  128. * Then it returns the template that matches. It is recursive.
  129. *
  130. * @uses debugger()
  131. * @uses dographquery()
  132. * @uses fastforward()
  133. * @uses addtostar()
  134. * @uses graphwalker()
  135. *
  136. * @param string $input The user's input
  137. * @param string $parent The word's parent ID
  138. * @param string $timesthrough Number of recursions????
  139. * @param boolean $onwild whether or not a wildcard is processed (Anne: I think)
  140. * @param string $parton Can be input, that, topic.
  141. * @param array &$inputstarvals contents of the *'s when they are part of the matching pattern input string
  142. * @param array &$thatstarvals contents of the *'s when they are part of the matching pattern that string
  143. * @param array &$topicstarvals contents of the *'s when they are part of the matching pattern topic string
  144. * @param array &$patternmatched contains all patterns that were found. A user's input can have more than one sentence.
  145. *
  146. * @return integer the Template ID to be returned.
  147. */
  148. function graphwalker($input,$parent,$timesthrough,$onwild,$parton,&$inputstarvals,&$thatstarvals,&$topicstarvals,&$patternmatched){
  149.  
  150. $curpmsize=0;
  151. //print "input: $input<BR>";
  152. debugger("Graphwalker called. Input|$input| Parent: $parent Timesthrough: $timesthrough Onwild: $onwild Parton: $parton",1);
  153.  
  154. $continuenode=1;
  155.  
  156. $oinputstarvals=$inputstarvals;
  157. $othatstarvals=$thatstarvals;
  158. $otopicstarvals=$topicstarvals;
  159.  
  160. $input=trim($input);
  161.  
  162. // If there is not a space in the input then use the whole input. Else get the first word from the input and put the rest of the input into $remains variable.
  163. if (strpos($input," ")===false){
  164. $word=$input;
  165. $remains="";
  166. }
  167. else {
  168. $word=substr($input,0,strpos($input," "));
  169. $remains=substr($input,strpos($input," "));
  170. }
  171.  
  172. debugger("Word|$word|",1);
  173. debugger("Remains|$remains|",1);
  174.  
  175. // Figure out which part we are on: input, that, or topic.
  176. if ($word=="<input>"){
  177. $parton="input";
  178. }
  179. elseif ($word=="<that>"){
  180. $parton="that";
  181. $patternmatched[]=":";
  182. }
  183. elseif ($word=="<topic>"){
  184. $parton="topic";
  185. $patternmatched[]=":";
  186. }
  187.  
  188. // See if the word we are on comes next in the graph we are walking or if a wildcard exists.
  189. //$query="select id,ordera,isend from patterns where (word='" . addslashes($word) . "' or word is null) and parent=$parent";
  190. //dographquery($query,$whichresult);
  191.  
  192. dographquery($whichresult, $word, $parent);
  193.  
  194. // Look for _ wildcard first because it is first "alphabetically"
  195. if (($whichresult[0]!=-1)&&($word!="<input>")&&($word!="<that>")&&($word!="<topic>")){
  196. // Don't keep looking in this portion of the graph - don't check for atomic or * because we matched already.
  197. $continuenode=-1;
  198.  
  199. debugger("processing an '_' here",2);
  200.  
  201. $patternmatched[]="_";
  202. $curpmsize=sizeof($patternmatched);
  203.  
  204. // If it is the last word in its context
  205. if ($whichresult[3]==1) {
  206. // The word we were on matched a wildcard so add the word to the star array.
  207. // Also it is the last word in this context so add everything up to the next context to the star.
  208. $ffremains=$remains;
  209. $newword=fastforward($word,$ffremains);
  210. addtostar($parton,$newword,$inputstarvals,$thatstarvals,$topicstarvals,1);
  211.  
  212. // Now we take off the first word and everything up to the next context because it matched and call the graphwalker
  213. $retvalue = graphwalker($ffremains,$whichresult[0],1,1,$parton,$inputstarvals,$thatstarvals,$topicstarvals,$patternmatched);
  214. }
  215. else {
  216.  
  217. // The word we were on matched a wildcard so add the word to the star array.s
  218. addtostar($parton,$word,$inputstarvals,$thatstarvals,$topicstarvals,1);
  219.  
  220. // Now we take off the first word because it matched and call the graphwalker
  221. $retvalue = graphwalker($remains,$whichresult[0],1,1,$parton,$inputstarvals,$thatstarvals,$topicstarvals,$patternmatched);
  222. }
  223.  
  224. // If the graphwalker returns blank then it never found a match. If it got a match we return it.
  225. if ($retvalue!=""){
  226. debugger("Retvalue from graphwalker not blank. Returning it",2);
  227. return $retvalue;
  228. }
  229. // If it didn't match then we continue on down the current node but next check for an atomic match.
  230. else {
  231. debugger("Returning a new call to graphwalker1. Input: $input Parent: $parent",2);
  232.  
  233. // Revert back to our original starvals
  234. $inputstarvals=$oinputstarvals;
  235. $thatstarvals=$othatstarvals;
  236. $topicstarvals=$otopicstarvals;
  237.  
  238. $curpdiff=sizeof($patternmatched) - $curpmsize;
  239.  
  240. for ($curpc=0;$curpc<=$curpdiff;$curpc++){
  241. array_pop($patternmatched);
  242. }
  243.  
  244. // Ensure that we continue looking for a match.
  245. $continuenode=1;
  246. }
  247.  
  248. }
  249.  
  250. // Look for an atomic match. Atomic match is where the whole word matches identically.
  251. if (($whichresult[1]!=-1)&&($continuenode==1)){
  252. $continuenode=-1;
  253.  
  254. // If we found a result and our word was "" then we have reached the end of the pattern so we return the template associated.
  255. if ($word==""){
  256. debugger("Result not blank and word is. Returning the found temlate",2);
  257. #return findtemplate($whichresult[1]);
  258. return $whichresult[1];
  259. }
  260. // If it is not the end of the pattern we keep going
  261. else {
  262.  
  263. if (($word!="<input>")&&($word!="<that>")&&($word!="<topic>")){
  264.  
  265. $patternmatched[]=$word;
  266. $curpmsize=sizeof($patternmatched);
  267. }
  268.  
  269. debugger("Result not blank and word is not blank. Calling graphwalker.",2);
  270. // We take off the first word and call the graphwalker again.
  271. $retvalue = graphwalker($remains,$whichresult[1],1,0,$parton,$inputstarvals,$thatstarvals,$topicstarvals,$patternmatched);
  272.  
  273. // If we got a match we return it
  274. if ($retvalue!=""){
  275. debugger("Retvalue from graphwalker not blank. Returning it",2);
  276. return $retvalue;
  277. }
  278. // Else we continue down our current node alphabetically to *
  279. else {
  280. $curpdiff=sizeof($patternmatched) - $curpmsize;
  281.  
  282. for ($curpc=0;$curpc<=$curpdiff;$curpc++){
  283. array_pop($patternmatched);
  284. }
  285. $continuenode=1;
  286.  
  287. }
  288. }
  289. }
  290.  
  291. // Will this if statement make things much faster???
  292. //if (($word=="<input>")||($word=="<that>")||($word=="<topic>")){
  293. // debugger("WORD MATCHED INPUT THAT OR TOPIC - RETURNING BLANK");
  294. // return "";
  295. //}
  296.  
  297.  
  298.  
  299. // Look for *
  300. if (($whichresult[2]!=-1)&&($continuenode==1)&&($word!="<input>")&&($word!="<that>")&&($word!="<topic>")){
  301. debugger("Looking for a '*' here",2);
  302. debugger("Result not blank and word is not blank. Calling graphwalker.",2);
  303.  
  304. $patternmatched[]="*";
  305. $curpmsize=sizeof($patternmatched);
  306.  
  307. // If it is the last word in its context
  308. if ($whichresult[5]==1) {
  309.  
  310. $ffremains=$remains;
  311. $newword=fastforward($word,$ffremains);
  312.  
  313. addtostar($parton,$newword,$inputstarvals,$thatstarvals,$topicstarvals,1);
  314.  
  315. // Call graphwalker with the first word removed from input
  316. $retvalue = graphwalker($ffremains,$whichresult[2],1,1,$parton,$inputstarvals,$thatstarvals,$topicstarvals,$patternmatched);
  317. }
  318. else {
  319.  
  320. addtostar($parton,$word,$inputstarvals,$thatstarvals,$topicstarvals,1);
  321.  
  322. // Call graphwalker with the first word removed from input
  323. $retvalue = graphwalker($remains,$whichresult[2],1,1,$parton,$inputstarvals,$thatstarvals,$topicstarvals,$patternmatched);
  324. }
  325.  
  326. // If found result then return it up.
  327. if ($retvalue!=""){
  328. debugger("Retvalue from graphwalker not blank. Returning it",2);
  329. return $retvalue;
  330. }
  331. else {
  332. $curpdiff=sizeof($patternmatched) - $curpmsize;
  333.  
  334. for ($curpc=0;$curpc<=$curpdiff;$curpc++){
  335. array_pop($patternmatched);
  336. }
  337. }
  338.  
  339. }
  340.  
  341. // Else no match found...
  342. if ((($whichresult[0]==-1)&&($whichresult[1]==-1)&&($whichresult[2]==-1))||($continuenode==1)) {
  343. //If we were most recently on a wildcard (*,_) then we are still matching it.
  344. if (($onwild==1)&&($word!="")&&($word!="<that>")&&($word!="<topic>")){
  345. debugger("On wild and in *. keep going with graphwalker.",2);
  346.  
  347. addtostar($parton,$word,$inputstarvals,$thatstarvals,$topicstarvals,2);
  348.  
  349. return graphwalker($remains,$parent,1,1,$parton,$inputstarvals,$thatstarvals,$topicstarvals,$patternmatched);
  350. }
  351. else {
  352. //We didn't find anything. We need to come back out
  353. debugger("Result is blank from query in *. Returning blank",2);
  354. return "";
  355. }
  356.  
  357. }
  358.  
  359. }
  360.  
  361. /**
  362. * Does a database query for {@link graphwalker()}
  363. *
  364. * Retrieves the ID, ordera, isend of the word to be searched
  365. * $query="select id,ordera,isend from patterns where word='" . addslashes($word) . "' or word is null and parent=$parent";
  366. *
  367. * @todo The array returned is also returned via call-by-reference. Investigate which should be chosen.
  368. *
  369. * @uses debugger()
  370. *
  371. * @global integer The number of queries that have been executed
  372. *
  373. * @param string $query The SQL code to be executed
  374. * @param array &$whichresult contains ID, ordera and isend from the query. note: call-by-reference
  375. *
  376. * @return array contains ID, ordera and isend from the query. note: call-by-reference array exists too.
  377. */
  378. function dographquery(&$whichresult, $word, $parent){
  379.  
  380. $query="select id,ordera,isend from patterns where (word='" . addslashes($word) . "' or word is null) and parent=$parent";
  381.  
  382.  
  383. global $numselects;
  384. $numselects++;
  385. debugger("dographquery: $query\n",2);
  386.  
  387. $whichresult[]=-1;
  388. $whichresult[]=-1;
  389. $whichresult[]=-1;
  390.  
  391. $whichresult[]=-1;
  392. $whichresult[]=-1;
  393. $whichresult[]=-1;
  394.  
  395. $selectcode = mysql_query($query);
  396. if ($selectcode){
  397. if(!mysql_numrows($selectcode)){
  398. return $whichresult;
  399. }
  400. else{
  401. while ($q = mysql_fetch_array($selectcode)){
  402. if ($q[1]==1){
  403. $whichresult[0]=$q[0];
  404.  
  405. // If it is the last word in its context.
  406. if ($q[2]==1){
  407. $whichresult[3]=1;
  408. }
  409.  
  410. }
  411. elseif ($q[1]==2){
  412. $whichresult[1]=$q[0];
  413.  
  414. // If it is the last word in its context.
  415. if ($q[2]==1){
  416. $whichresult[4]=1;
  417. }
  418.  
  419. }
  420. elseif ($q[1]==3){
  421. $whichresult[2]=$q[0];
  422.  
  423. // If it is the last word in its context.
  424. if ($q[2]==1){
  425. $whichresult[5]=1;
  426. }
  427.  
  428. }
  429.  
  430.  
  431. }
  432. return $whichresult;
  433. }
  434. }
  435.  
  436. }
  437.  
  438.  
  439.  
  440. /**
  441. * Retrieve the template from the templates table
  442. *
  443. * Get the template from the templates table. and return it.
  444. *
  445. * @todo The name {@link gettemplate()} and findtemplate() are too similar.
  446. *
  447. * @param integer $id The ID of the template to be returned
  448. *
  449. * @return string The contents of <template/> for this category.
  450. */
  451. function findtemplate($id){
  452.  
  453. $query = "select template from templates where id=$id";
  454. debugger($query,2);
  455. $selectcode = mysql_query($query);
  456. if ($selectcode){
  457. if(!mysql_numrows($selectcode)){
  458. return "";
  459. }
  460. else{
  461. while ($q = mysql_fetch_array($selectcode)){
  462. return $q[0];
  463. }
  464. }
  465. }
  466.  
  467. return "";
  468. }
  469.  
  470.  
  471. /**
  472. * Deals with creating and adding to the star arrays
  473. *
  474. * If a * or _ is part of the matched pattern, what is covered by that variable is then stored in the 'star arrays'. This function creates and adds words to that array or array element.
  475. *
  476. * @param string $parton Can be input, that, topic.
  477. * @param string $word The word that needs to be stored
  478. * @param array &$inputstarvals contents of the *'s when they are part of the matching pattern input string
  479. * @param array &$thatstarvals contents of the *'s when they are part of the matching pattern that string
  480. * @param array &$topicstarvals contents of the *'s when they are part of the matching pattern topic string
  481. * @param integer $action what action needs to be done, append to existing or create new.
  482. *
  483. * @return void info is returned via call-by-reference variables.
  484. */
  485. function addtostar($parton,$word,&$inputstarvals,&$thatstarvals,&$topicstarvals,$action){
  486.  
  487. if (($word!="<nothing>")&&($word!="<that>")&&($word!="<topic>")){
  488.  
  489. if ($parton=="input"){
  490.  
  491. // Action 1 is adding a new star
  492. if ($action==1){
  493. $inputstarvals[]=$word;
  494. }
  495. // Action 2 is appending to existing star
  496. elseif ($action==2){
  497. $inputstarvals[sizeof($inputstarvals)-1].= " " . $word;
  498. }
  499. }
  500. elseif ($parton=="that"){
  501.  
  502. if ($action==1){
  503. $thatstarvals[]=$word;
  504. }
  505. elseif ($action==2){
  506. $thatstarvals[sizeof($thatstarvals)-1].= " " . $word;
  507. }
  508.  
  509. }
  510. elseif ($parton=="topic"){
  511.  
  512. if ($action==1){
  513. $topicstarvals[]=$word;
  514. }
  515. elseif ($action==2){
  516. $topicstarvals[sizeof($topicstarvals)-1].= " " . $word;
  517. }
  518.  
  519. }
  520.  
  521. }
  522. }
  523.  
  524.  
  525. /**
  526. * Fast forward to the processing of the next context
  527. *
  528. * Remainder of the user's input covered by a *. So so add everything up to the next context (<that> & <topic>) to the star.
  529. *
  530. * @todo $newremains is a variable that is created, and filled but not returned. It is perhaps old code that
  531. * pre dates {@link addtostar()} that saves the returned value in {@link graphmaster()}.
  532. *
  533. *
  534. * @param string $word Current processed word
  535. * @param string $ffremains Words that remain to be processed.
  536. *
  537. * @return string words to be saved by {@link addtostar()}
  538. */
  539. function fastforward($word,$ffremains){
  540.  
  541. $starwords=$word;
  542.  
  543. $newremains="";
  544.  
  545. $ffremains=trim($ffremains);
  546. $ffar=split(" ",$ffremains);
  547.  
  548. $x=0;
  549. $currentword=$ffar[$x];
  550.  
  551. while (($currentword!="<that>")&&($currentword!="<topic>")&&($currentword!="")){
  552.  
  553. $starwords = $starwords . " " . $currentword;
  554. $x++;
  555.  
  556. if ($x>=sizeof($ffar)){
  557. break;
  558. } else {
  559. $currentword=$ffar[$x];
  560. }
  561.  
  562. }
  563.  
  564. for ($y=$x;$y<sizeof($ffar);$y++){
  565. $newremains = $newremains . " " . $ffar[$y];
  566. }
  567.  
  568. $ffremains=trim($newremains);
  569. return $starwords;
  570.  
  571. }
  572.  
  573.  
  574. /**
  575. * Check to see if exact input-that-topic exists in cache
  576. *
  577. * GmCache is a log that contains all unique entries. If the exact same input-that-topic is requested that is found in GmCache, then it's template reference is used instead of traversing the binary AIML tree. Saving response time.
  578. *
  579. * @param string $combined the complete input in <input>word word<that>word word<topic>word word format.
  580. * @param array &$inputstarvals contents of the *'s when they are part of the matching pattern input string
  581. * @param array &$thatstarvals contents of the *'s when they are part of the matching pattern that string
  582. * @param array &$topicstarvals contents of the *'s when they are part of the matching pattern topic string
  583. * @param array &$patternmatched all the patterns that match input, i.e. multiple sentences are kept seperate.
  584. * @param array &$inputmatched all the matched input.
  585. *
  586. * @return boolean true/false Note, info is also transfere through the call-by-reference variables.
  587. */
  588.  
  589. function checkcache($combined,&$template,&$inputstarvals,&$thatstarvals,&$topicstarvals,&$patternmatched,&$inputmatched)
  590. {
  591. $ccquery="select template,inputstarvals,thatstarvals,topicstarvals,patternmatched,inputmatched from gmcache where combined='" . addslashes($combined) . "' and " . whichbots();
  592.  
  593. $selectcode = mysql_query($ccquery);
  594. if ($selectcode){
  595. if(!mysql_numrows($selectcode)){
  596. return false;
  597. }
  598. else{
  599. while ($q = mysql_fetch_array($selectcode)){
  600.  
  601. $template=findtemplate($q[0]);
  602. $inputstarvals=split(",",$q[1]);
  603. $thatstarvals=split(",",$q[2]);
  604. $topicstarvals=split(",",$q[3]);
  605. $patternmatched=$q[4];
  606. $inputmatched=$q[5];
  607. return true;
  608. }
  609. }
  610. }
  611.  
  612. return false;
  613.  
  614. }
  615.  
  616.  
  617. /**
  618. * Add an entry in the GMcache table
  619. *
  620. * @global integer The selected bot.
  621. *
  622. * @param string $combined the complete input in <input>word word<that>word word<topic>word word format.
  623. * @param string $mytemplate the reply to the input
  624. * @param string $inputstarvals contents of the input star
  625. * @param string $thatstarvals contents of the that star
  626. * @param string $topicstarvals contents of the topic star
  627. * @param string $patternmatched the AIML category pattern that matches the input
  628. * @param string $inputmatched the input that matched the category.
  629. *
  630. * @return void
  631. */
  632. function fillcache($combined,$mytemplate,$inputstarvals,$thatstarvals,$topicstarvals,$patternmatched,$inputmatched)
  633. {
  634. global $selectbot;
  635. $ccquery="insert into gmcache (bot, combined,template,inputstarvals,thatstarvals,topicstarvals,patternmatched,inputmatched) values ($selectbot,'" . addslashes($combined) . "'," . $mytemplate . ",'" . addslashes(arraytostring($inputstarvals)) . "','" . addslashes(arraytostring($thatstarvals)) . "','" . addslashes(arraytostring($topicstarvals)) . "','" . addslashes($patternmatched) . "','" . addslashes($inputmatched) . "')";
  636.  
  637. $selectcode = mysql_query($ccquery);
  638. if ($selectcode){
  639. }
  640.  
  641. }
  642.  
  643.  
  644. /**
  645. * Turn an array into a string
  646. *
  647. * take each element of the array and put all of them into one big string; one after the other.
  648. *
  649. * @param array $myarray
  650. *
  651. * @return string the contents of the array into a string.
  652. */
  653. function arraytostring($myarray)
  654. {
  655. $retstring="";
  656.  
  657. for ($x=0;$x<sizeof($myarray);$x++){
  658. $retstring .= $myarray[$x] . ",";
  659. }
  660.  
  661. $retstring=substr($retstring,0,strlen($retstring)-1);
  662.  
  663. return $retstring;
  664.  
  665. }
  666.  
  667. ?>

Documentation generated on Wed, 12 Jan 2005 12:24:47 +0100 by phpDocumentor 1.3.0RC3