OK, I'll let you know what I'm trying to do:
1) I want to search the directory data/ for all the files ending in ".qwiki".
2) Then I want to make an array of all these file names without the ".qwiki".
3) Next I want to search all the files for strings matching either of 2 patterns (via pattern syntax) and put all the matches in an array.
4) then I want to get rid of all, if any, underscores in the values of the array.
5) Then I want to get rid of all repeating values, probably with array_unique.
6) lastly, I want to make an array of the differences between the file list array and the pattern match array.
so yeah, this is what I have so far:<?php
$pageList = array();
$links2 = array();
foreach(QWListFiles() as $list) {
if( strpos($list , ".qwiki" ) && !strpos($list, "QwikiWiki" ) ) {
$location = "data/" . $list;
$page1 = substr( $list, 0, strlen( $list ) - 6 );
$pageList[] = $page1;
preg_match_all( '/(^|[^\w_]+)([A-Z]+[a-z\d]+[A-Z]+\w*)($|[^\w_]+)/', QWGetFileContents( $location ), $out1 );
preg_match_all( '/(^|\W+)_([\w-]+(?:_[\w-]+)*)_($|\W+)/', QWGetFileContents( $location ), $out2 );
$links = array_merge($out1, $out2);
$links2[] = $links;
}
}
$finish = array_diff(array_unique($links2), $pageList);
foreach($finish as $fini) {
foreach($fini as $fin) {
foreach($fin as $fi) {
echo $fi . "<br>";
}
}
}
?> basically, I just want to get this code to do what I said I wanted. it's probably really messy because i'm a supern00b at php, so if you could help me clean it up a bit that 'd be appreciated.
thanks!why'd you start a new topic?
i already started answering in <!-- m --><a class="postlink" href="http://www.htmlforums.com/showthread.php?s=&threadid=43913sorry">http://www.htmlforums.com/showthread.ph ... 43913sorry</a><!-- m --> about that, I just figured it was a different questionseems more like a continuation - but that's okay...
have you got the first on bit done yet?I got #1 and #2 done with the script shown below, but everything gets weird after that and I can't tell. Keep in mind the array put out by #3 is going to be pretty big eventually, because its going to be every link on every page on the entire site put into one array. It's fairly manageable now, but when I do a print_r on the array it's a page or two of output. so i need help on #3 now.whoo hoo, I got to #5, but I'm having some troubles. I can't seem to do array_unique, because everything is in an individual array it just removes the multiple instances within each array.$pageList = array();
$links = array();
foreach(QWListFiles() as $list) {
if( strpos($list , ".qwiki" ) && !strpos($list, "QwikiWiki" ) ) {
$location = "data/" . $list;
$page1 = substr( $list, 0, strlen( $list ) - 6 );
$pageList[] = $page1;
preg_match_all( '/(^|[^\w_]+)([A-Z]+[a-z\d]+[A-Z]+\w*)($|[^\w_]+)/', QWGetFileContents( $location ), $out1 );
preg_match_all( '/(^|\W+)_([\w-]+(?:_[\w-]+)*)_($|\W+)/', QWGetFileContents( $location ), $out2 );
foreach($out1 as $in1) {
$links[] = $in1;
}
foreach($out2 as $in2) {
$links[] = $in2;
}
}
}
foreach($pageList as $listPage) {
echo $listPage . "<br>";
}
echo "<hr>";
foreach($links as $linklist) {
$cleaned = preg_replace('/\W/' , '' , $linklist);
$superclean = QWCleanQwikiPageName($cleaned);
$unique = array_unique($superclean);
echo "<hr>";
foreach($unique as $linklist2) {
echo $linklist2 . "<br>";
}
}
I think I need to merge all the arrays and then do the array_unique, but I'm not sure how to go about this. I know of array_merge.
I need to know how to use array_merge to merge all arrays within an array. The array '$links' has a bunch of arrays in it, and i need to know how to get all of the values of those arrays to become the values of one array.problem solved
1) I want to search the directory data/ for all the files ending in ".qwiki".
2) Then I want to make an array of all these file names without the ".qwiki".
3) Next I want to search all the files for strings matching either of 2 patterns (via pattern syntax) and put all the matches in an array.
4) then I want to get rid of all, if any, underscores in the values of the array.
5) Then I want to get rid of all repeating values, probably with array_unique.
6) lastly, I want to make an array of the differences between the file list array and the pattern match array.
so yeah, this is what I have so far:<?php
$pageList = array();
$links2 = array();
foreach(QWListFiles() as $list) {
if( strpos($list , ".qwiki" ) && !strpos($list, "QwikiWiki" ) ) {
$location = "data/" . $list;
$page1 = substr( $list, 0, strlen( $list ) - 6 );
$pageList[] = $page1;
preg_match_all( '/(^|[^\w_]+)([A-Z]+[a-z\d]+[A-Z]+\w*)($|[^\w_]+)/', QWGetFileContents( $location ), $out1 );
preg_match_all( '/(^|\W+)_([\w-]+(?:_[\w-]+)*)_($|\W+)/', QWGetFileContents( $location ), $out2 );
$links = array_merge($out1, $out2);
$links2[] = $links;
}
}
$finish = array_diff(array_unique($links2), $pageList);
foreach($finish as $fini) {
foreach($fini as $fin) {
foreach($fin as $fi) {
echo $fi . "<br>";
}
}
}
?> basically, I just want to get this code to do what I said I wanted. it's probably really messy because i'm a supern00b at php, so if you could help me clean it up a bit that 'd be appreciated.
thanks!why'd you start a new topic?
i already started answering in <!-- m --><a class="postlink" href="http://www.htmlforums.com/showthread.php?s=&threadid=43913sorry">http://www.htmlforums.com/showthread.ph ... 43913sorry</a><!-- m --> about that, I just figured it was a different questionseems more like a continuation - but that's okay...
have you got the first on bit done yet?I got #1 and #2 done with the script shown below, but everything gets weird after that and I can't tell. Keep in mind the array put out by #3 is going to be pretty big eventually, because its going to be every link on every page on the entire site put into one array. It's fairly manageable now, but when I do a print_r on the array it's a page or two of output. so i need help on #3 now.whoo hoo, I got to #5, but I'm having some troubles. I can't seem to do array_unique, because everything is in an individual array it just removes the multiple instances within each array.$pageList = array();
$links = array();
foreach(QWListFiles() as $list) {
if( strpos($list , ".qwiki" ) && !strpos($list, "QwikiWiki" ) ) {
$location = "data/" . $list;
$page1 = substr( $list, 0, strlen( $list ) - 6 );
$pageList[] = $page1;
preg_match_all( '/(^|[^\w_]+)([A-Z]+[a-z\d]+[A-Z]+\w*)($|[^\w_]+)/', QWGetFileContents( $location ), $out1 );
preg_match_all( '/(^|\W+)_([\w-]+(?:_[\w-]+)*)_($|\W+)/', QWGetFileContents( $location ), $out2 );
foreach($out1 as $in1) {
$links[] = $in1;
}
foreach($out2 as $in2) {
$links[] = $in2;
}
}
}
foreach($pageList as $listPage) {
echo $listPage . "<br>";
}
echo "<hr>";
foreach($links as $linklist) {
$cleaned = preg_replace('/\W/' , '' , $linklist);
$superclean = QWCleanQwikiPageName($cleaned);
$unique = array_unique($superclean);
echo "<hr>";
foreach($unique as $linklist2) {
echo $linklist2 . "<br>";
}
}
I think I need to merge all the arrays and then do the array_unique, but I'm not sure how to go about this. I know of array_merge.
I need to know how to use array_merge to merge all arrays within an array. The array '$links' has a bunch of arrays in it, and i need to know how to get all of the values of those arrays to become the values of one array.problem solved