carlosvega1 Posted November 30, 2008 Share Posted November 30, 2008 Hey so i was wondering if there was a way to take the entries of the arrays in: http://wookeh.net/csc4900/OAT/test.php and compare them with the different files in http://wookeh.net/csc4900/OAT/index2.php for Example Array ( [0] => Array ( [0] => ART 2020 Introduction to Digital Arts [1] => ART 2050 Art Appreciation [2] => ART 2080 Survey of Art I [3] => ART 2090 Survey of Art II This whole section would check the art txt file and output the entry http://wookeh.net/csc4900/OAT/art.txt ART 2020 is an opportunity, for non-Art majors, for introductory study and activity in various contemporary means of visual communication and design thinking practiced through digital means. The DAA 2020 curriculum is focused both on digital literacy and on design thinking. As such students will find both computers and working creatively with computers and related technologies co-equal foci of this course. DAA 2020 is open to all students and has no prerequisites. Credit, 3 semester hours. ART 2050. Art Appreciation A course designed to establish an understanding of art, to develop an appreciation for the relation between art and man, and to study the cultural and historical contexts of artistic production and reception. Credit, 3 semester hrs. ART 2090. Survey of Art II: Renaissance through Contemporary An overview of painting, sculpture, architecture, and related visual arts of major world cultures from the Renaissance to the present, including European, American, Asian, African, and Islamic art. Major artistic developments and their cultural contexts will be emphasized. Credit, 3 semester hours. all in a different php file or txt document... Link to comment https://forums.phpfreaks.com/topic/134903-php-array-help/ Share on other sites More sharing options...
carlosvega1 Posted December 1, 2008 Author Share Posted December 1, 2008 OK to clarify... http://wookeh.net/csc4900/OAT/test.php the code is: <?php $file = file_get_contents("http://www.uncp.edu/catalog/html/acad_prog.htm"); preg_match_all('~<p class=gened4>(.*?)</p>~is', $file, $genEds); //$matches will be an array with full pattern match as first element and parenthesized pattern match as second element echo '<pre>', print_r($genEds, true), '</pre>'; //If there's more than one p tag with class="sample", you can use preg_match_all() instead, to grab the contents of all of them ?> which grabs all the gen ed courses from a list on another website and puts them all into an array... then from that i have individual files on http://wookeh.net/csc4900/OAT/ like the file http://wookeh.net/csc4900/OAT/art.php <?php $file = file_get_contents("http://www.uncp.edu/catalog/html/art.htm"); preg_match_all('~<p class=Coursename>(.*?)</p>~is', $file, $matches); //$matches will be an array with full pattern match as first element and parenthesized pattern match as second element echo '<pre>', print_r($matches, true), '</pre>'; //If there's more than one p tag with class="sample", you can use preg_match_all() instead, to grab the contents of all of them $file2 = file_get_contents("http://www.uncp.edu/catalog/html/art.htm"); preg_match_all('~<p class=Coursedescription>(.*?)</p>~is', $file2, $matches1); //$matches will be an array with full pattern match as first element and parenthesized pattern match as second element echo '<pre>', print_r($matches1, true), '</pre>'; //If there's more than one p tag with class="sample", you can use preg_match_all() instead, to grab the contents of all of them //start an empty array. $finalArray = array(); //loop through the courses. foreach($matches[1] as $key=>$value){ //assign matching 'Course' and 'Description' values. $finalArray[$key]['Coursename'] = strip_tags($value); $finalArray[$key]['Description'] = strip_tags($matches1[0][$key]); } //display the final array. print_r($finalArray); //these arrays should be similar to the ones you posted $courses = $finalArray; $data = ''; foreach ($courses as $chunk) { foreach ($chunk as $course) { $data .= "$course\r\n"; //windows line break at end of each line } } $handle = fopen('art.txt', 'w'); //if file exists, truncate it, else attempt to create it fwrite($handle, $data); fclose($handle); ?> Which reads another document and combines the class like ART 1010. Elements of Design and combines it with its description... A study and application of design principles in creative two‑dimensional projects in line, value, color and texture. Credit, 3 semester hours. then it outputs the class with the description in a seperate text file.. http://wookeh.net/csc4900/OAT/art.txt now what i want to do is check http://wookeh.net/csc4900/OAT/test.php which is the original gen ed files.. like in this example check the http://wookeh.net/csc4900/OAT/art.txt for the class ART 2020 Introduction to Digital Arts and output in a new file the class and its description.. but for all the defirrent gen eds... Link to comment https://forums.phpfreaks.com/topic/134903-php-array-help/#findComment-702731 Share on other sites More sharing options...
carlosvega1 Posted December 1, 2008 Author Share Posted December 1, 2008 anyone with input? Link to comment https://forums.phpfreaks.com/topic/134903-php-array-help/#findComment-702987 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.