PHP - Preg_grep Find A Partial Match In A Array Of Strings Then Compare To The Original And Display The Output
Hi I am trying to search an array that comes from a power shell script, the array of strings that returns is ever changing as it receives variables from the script. Therefore I need to use preg_grep to search for the word "not" I am also using another array which inverts this I then need to compare these new two arrays to the original and separate the results $working and not working into a table. I would be most grateful for any advice/solutions. The preg_grep aren't displaying anything.
<?php
//phpinfo();
ini_set('display_errors', 'On');
error_reporting(0);//E_ALL
echo '<html>
<style>
body
{
font-family:Calibri,Helvetica,sans-serif;
font-size:100%;
}
</style>
<head>
<link rel="stylesheet" type="text/css" href="style.css">
<script type="text/javascript">
function uploadJS(){
String.prototype.trim = function() { return this.replace(/^\s+|\s+$/g, ""); };
var textAreaValue=document.getElementById(\'ServerList\').value;
var trimmedTextAreaValue=textAreaValue.trim();
if(trimmedTextAreaValue!="") {
document.myForm.submit();
} else{
alert("Server List Text Area is Empty");
}
};
var input=document.getElementById(\'fileSelect\').value;
if(input!="") {
document.myForm.submit();
} else{
alert("You have not selected a file, please select one to proceed.");
}
var handleFileSelect = function(e) {
var files = e.target.files;
if(files.length === 1) {
document.forms.myForm.filecsv.value = files[0].name;
}
}
};
</script>
</head>';
#Upload Code
$target = "D:\Web\Upload/";
$target = $target . basename( $_FILES['uploaded']['name']) ;
$ok=1;
if(move_uploaded_file($_FILES['uploaded']['tmp_name'], $target))
{
echo "The file ". basename( $_FILES['uploadedfile']['name']). "
has been uploaded";
}
else {
}
if ($uploaded_size > 150000)
{ echo "Your file is too large.<br>";
$ok=0;
}
if ($uploaded_type =="text/php")
{
echo "No PHP files<br>";
$ok=0;
}
if (!($uploaded_type=="text/csv")) { echo "<br>";
$ok=0;
}
$target = "upload/"; $target = $target . basename( $_FILES['uploaded']['name']) ; $ok=1; //This is our size condition
if ($uploaded_size > 350000)
{
echo "Your file is too large.<br>";
$ok=0;
}
//This is our limit file type condition
if ($uploaded_type =="text/php")
{ echo "No PHP files<br>";
$ok=0;
}
//Here we check that $ok was not set to 0 by an error
if ($ok==0)
{
}
//If everything is ok we try to upload it
else {
if(move_uploaded_file($_FILES['uploaded']['tmp_name'], $target))
{
echo "The file ". basename( $_FILES['uploadedfile']['name']). " has been uploaded";
} else
{
}
}
#Start of scripts to check Servers in textbox
if(isset($_POST['ServerList']))
{
//$arry=explode( "\r\n", $_POST['ServerList'] );
$txttrim = trim($_POST['ServerList']);
//$textAr = explode("\n", $text);
//$textAr1 = array_filter($text, 'trim'); // remove any extra \r characters left behind
$txtarea = explode("\n",$txttrim);
$txtarea = array_filter($txtarea,'trim');
foreach ($txtarea as $line => $servername)
{
//$line => $servername;
##check if querying itself....
}
echo '<pre>';
$target="D:/Web/Upload/"; $target= $target . basename( $_FILES['uploaded']['name']) ;
$csv = $target;
//$filename= $_FILES['uploaded']['name'];
$output=shell_exec("powershell -Command D:/Web/scripts/PHPfwrules.ps1 $csv < NUL");
echo '<h6>';
print_r($output);
$nomatch=preg_grep('/^not/i',$output);
echo $nomatch;
$match=preg_grep("/not/",$output,PREG_GREP_INVERT);
echo $match;
if ($working1= array_intersect($output,$match))
{
echo"<link rel=stylesheet type=text/css href=style.css>
<table class=results>
<tr>
<th>Server Name</th>
<th>Working</th>
</tr>
<tr>
<td>".$servername."</td>
<td>".$working1."</td>
</tr></table>
";
}
else if ($notworking1= array_intersect($output,$nomatch))
{
echo"<link rel=stylesheet type=text/css href=style.css>
<table class=results>
<tr>
<th>Server Name</th>
<th>Not Working</th>
</tr>
<tr>
<td>".$servername."</td>
<td>".$notworking1."</td>
</tr></table>
";
}
}
echo' <link rel=stylesheet href=dhtmlwindow.css type=text/css />
<link rel=stylesheet type=text/css href=style.css>
<script src=js/dhtmlwindow.js></script>
<hr />
<table class=results>
<tr>
<th>Server Name</th>
<th>Working</th>
<th> Not Working</th>
</tr>
<tr>
<td>'.$servername.'</td>
<td>'.$working1.'</td>
<td>'.$notworking1.'</td>
<td></td>
';
echo '</pre>';
echo '
<h3>Firewall Implementation </h3>
<h4>Please enter the server below, you can only select one server at a time. </h4>
<!--The form-->
<form action="fw2.php" method="post" name="myForm" id="myForm" enctype="multipart/form-data">
<textarea name=ServerList id=ServerList>
</textarea>
<h5>Please select a CSV file.</h5>
<input name="uploaded" type="file" /><br />
<input type="submit" value="Submit" />
<br>
</html> '
;
?>
Similar TutorialsI have a cart script, and I need to display the products the user has added. This is a school assignment and I'm very stuck on this seemingly 'little' error. Right now, I have two tables: For time's sake, I am showing duplicate products with different prod_id's: Table: products prod_id category sub_category thumb_href image_href title desc summary manufacturer price 17 sofa leather red_leather_sofa_small.jpg red_leather_sofa_main.jpg Red Leather Sofa [BLOB - 134B] [BLOB - 59B] Balenty 999.99 18 sofa leather red_leather_sofa_small.jpg red_leather_sofa_main.jpg Red Leather Sofa [BLOB - 134B] [BLOB - 59B] Balenty 999.99 19 sofa leather red_leather_sofa_small.jpg red_leather_sofa_main.jpg Red Leather Sofa [BLOB - 134B] [BLOB - 59B] Balenty 999.99 And this is the cart table that holds temporary cart items (storing the product ID to pull later): Table: cart temp_cart_item cart_id (assigned by session_id() ) prod_id user_id 22 jier11u0e7cl2ghosjodpaark2 17 asdfasdf 23 jier11u0e7cl2ghosjodpaark2 17 asdfasdf 24 jier11u0e7cl2ghosjodpaark2 35 asdfasdf 25 jier11u0e7cl2ghosjodpaark2 5 asdfasdf 26 jier11u0e7cl2ghosjodpaark2 19 asdfasdf SO, user 'asdfasdf' is logged in and has selected 5 items for his cart - two of which are the same (prod_id 17). Basically, I need to compare the prod_id's of each table and output all products (and quantities) matching the temporary cart prod_id. What I have now to loop through and display the cart items are (bear with me): echo "<h1>Cart</h1>"; } // Display welcome and navigation links displayWelcome(); displayNav(); // Getting the prod_id's from the table cart to compare with the product table $cart_id = session_id(); $user_id = ($_SESSION['login_username']); $query = "SELECT prod_id FROM cart WHERE cart_id='$cart_id' AND user_id='$user_id'"; $result = mysqli_query($cxn,$query) or die("<h2 class=\"warning\">Whoa! Problem with the cart script here!</h2>"); $nrows = mysqli_num_rows($result); if($nrows < 1) { echo "<h2>Your cart is empty</h2><p><a href=\"catalog.php\">Go back to the catalog</a></p>"; } else { // Continue to gather products for all the product IDs in the products DB table... echo "<h4>$nrows items in your cart</h4>"; while($row = mysqli_fetch_array( $result )) { $user_id = ($_SESSION['login_username']); $product = $row['prod_id']; // Is the query my problem? $query = "SELECT * FROM products WHERE prod_id='$product'"; $result = mysqli_query($cxn,$query) or die("<h2 class=\"warning\">Whoa! Problem with the cart script here!</h2>"); $nrows = mysqli_num_rows($result); if($nrows < 1) { // If the item doesn't exist, display an error echo "<h2>That is not a valid product, or any of the items you had in your cart are missing or have been deleted.</h2><p><a href=\"catalog.php\">Go back to the catalog</a></p>"; // Protect from continually displaying an error by deleting the invalid cart record $deletequery = "DELETE FROM cart WHERE prod_id='$product'"; $deleteresult = mysqli_query($cxn,$deletequery) or die("<h2 class=\"warning\">Whoa! Problem with the cart script here!</h2>"); exit(); } while($row = mysqli_fetch_array( $result )) { // Then disply them in a table echo "<h2>Items in Your Cart:</h2>"; echo " <table id=\"products\"> <thead> <tr> <th class=\"col1 headercol\" scope=\"col\">Thumbnail</th> <th class=\"col2 headercol\" scope=\"col\">Summary</th> <th class=\"col3 headercol\" scope=\"col\">Manufacturer</th> <th class=\"col4 headercol\" scope=\"col\">Price</th> </tr> </thead> <tbody>\n"; $query = "SELECT SUM(price) FROM products WHERE prod_id='$product' GROUP BY price"; $priceResult = mysqli_query($cxn,$query) or die("<h2 class=\"warning\">Whoa! Problem with the cart script here!</h2>"); // keeps getting the next row until there are no more to get // Print out the contents of each row into a table echo "<tr> <td class=\"col1\">"; echo "<a class=\"imgHref\" href=\"detail.php?prod_id=".$row['prod_id']."\" title=\"".$row['title']."\"><img src=\"../images/".$row['thumb_href']."\" alt=\"".$row['title']."\" /></a>"; echo "</td>\n"; echo " <td class=\"col2\">"; echo "<h3 class=\"title\"><a href=\"detail.php?prod_id=".$row['prod_id']."\" title=\"".$row['title']."\">".$row['title']."</a> <span class=\"inlineh3\">by <a href=\"categories.php?manufacturer=".$row['manufacturer']."\" title=\"View all products by ".$row['manufacturer']."\">".$row['manufacturer']."</a></span></h3>"; echo "<p class=\"summary\">".$row['summary']."</p> <p class=\"descHeading\">&#9758; <em>Full Description:</em></p> <p class=\"desc\">".$row['desc']."</p>"; echo "</td>\n"; echo " <td class=\"col3\">"; echo "<p class=\"manufacturer\"><a href=\"categories.php?manufacturer=".$row['manufacturer']."\" title=\"View all products by ".$row['manufacturer']."\">".$row['manufacturer']."</a></p>"; echo "</td>\n"; echo " <td class=\"col4\">"; echo "<p class=\"price\">$".$row['price']."</p>"; echo "</td> </tr>\n"; } while($priceRow = mysqli_fetch_array( $priceResult )) { echo "<tr class=\"short\"><td class=\"col1\"><h3><a href=\"clear_cart.php\">Empty Cart</a></h3></td><td class=\"col2\"></td><td class=\"col3 nobackground\">Total:</td><td class=\"col4\">$".$priceRow[0]."</td></tr>"; } echo "</tbody> </table>"; echo "<p class=\"submitOrder\"><form action='submit_order.php' method='post' id='form'> <input type='submit' name='pButton' value='Submit Order'> <input name='order_total' type='hidden' id='order_total' value='".$priceRow[0]."' /> </form> </p>"; } } And so the cart.php looks something like this (this example asdfasdf has 6 items in his cart): So you can see that it only displays ONE item, even though asdfasdf DOES have 6 items in his cart (proven by checking database). And the price is not accurate, either. Can anyone help me in where my problem might be? Is it my query? Or my while clause? I have a array of file path strings and trying to search the array for a string that would be the end of the path sting and return the index of the file path that contains the string. I've tried using something like this, but it finds the keyword in anyplace in the file path. I've also tried strripos() as well with the same results. Any suggestions? function array_search_partial($arr, $keyword) { foreach ($arr as $index => $string) { if(strpos($string, $keyword) !== FALSE) { return $index; } } }
$color=array("01 orange","02 blue","03 red"); If my array was structured this way where the first two characters represented a code, how would I be able to display the code and color distinctly? Not sure if there is a better way to do this, but I want to check whether the value in a Sticky Field is the same as what is in the Database. If what is in the Sticky Field is *exactly* what is in the Database, then the User didn't update that field, and so I would NOT do an UPDATE. Seem reasonable? Here is where I grab the value out of the Form... Code: [Select] // **************************** // Process Each Form Field. * // **************************** foreach($_POST['answerArray'] as $questionID => $response){ // Copy trimmed Form array to PHP array. $answerArray[$questionID] = trim($response); And here is where I grab the existing value in the Database... Code: [Select] // ******************** // Check for Answer. * // ******************** // Build query. $q1 = "SELECT response FROM bio_answer WHERE member_id=? AND question_id=?"; // Prepare statement. $stmt1 = mysqli_prepare($dbc, $q1); // Bind variable to query. mysqli_stmt_bind_param($stmt1, 'ii', $memberID, $questionID); // Execute query. mysqli_stmt_execute($stmt1); // Store results. mysqli_stmt_store_result($stmt1); // Check # of Records Returned. if (mysqli_stmt_num_rows($stmt1)==1){ // Answer Found. // Bind result-set to variable. mysqli_stmt_bind_result($stmt1, $currResponse); // Fetch record. mysqli_stmt_fetch($stmt1); So I guess I want to compare $answerArray[$questionID] against $currResponse and see if there are any differences?! What is the best way to do that? Any better ideas of how to check to see if the User made any changes to a field so I only do an UPDATE if there was actually a change? Thanks, Debbie I have following working code to compare 2 csv files - base.csv file to compare to master.csv file using function row_compare. For now I am echoing the master.csv file followed by echoing the match items. I need help to echo only the master.csv file in a table format and highlight the rows that match the base.csv files items. function row_compare($a, $b) { if ($a === $b) { return 0; } return (implode("",$a) < implode("",$b) ) ? -1 : 1; } $file1 = new SplFileObject("master.csv"); $file1->setFlags(SplFileObject::READ_CSV); $file2 = new SplFileObject("../../base.csv"); $file2->setFlags(SplFileObject::READ_CSV); foreach ($file1 as $row) { $csv_1[] = $row; } foreach ($file2 as $row) { $csv_2[] = $row; } $unique_to_csv1 = array_udiff($csv_1, $csv_2, 'row_compare'); $unique_to_csv2 = array_udiff($csv_2, $csv_1, 'row_compare'); $all_unique_rows = array_merge($unique_to_csv1,$unique_to_csv2); foreach($all_unique_rows as $unique_row) { foreach($unique_row as $element) { echo $element . " "; } echo '<br />'; }
Although I am deciding on the best route to go on this, I was hoping for any feedback or ideas on the best and simplest approach to the below problem: Here is my table structu old_code_1 old_code_2 new_code_1 new_code_2 prod_code_1 prod_code_2 Each of the following fields has 5 digits e.g. 00045, 12654, etc. What I need to achieve is this: Concatenate each set (of the 3 sets above) data into one variable e.g. old_code_1 + old_code_2 = 0004512654. So old_code_1 & old_code_2 would become a combined data and the same for the othe 2 sets. Then. Once concatenated, I need to compa prod_code_1+prod_code_2 with old_code_1+old_code_2 and replace prod_code_1+prod_code_2 with new_code_1+new_code_2 where matches are found. The new_code_1 & 2 are in the same row as the old_code 1 & 2. So the data is in alignment that way for comparison. Thanks for any insight or suggestions on how to make this happen in the simplest form possible. Let's say for example I have 3 ID's in ONE database row like this: name: values: page ids 17 23 32 And I have a list of page titles with the ID's of the pages inserted into the value field of a checkbox. [] page title 1 [] page title 2 [] page title 3 [] page title 4 [] page title 5 [] page title 6 What I Want to Do! I want to fetch the page ID's from the database and I want a way to see if there match any page ID's from the list with the page ID's from the database row. Based on that I want to run an if statement. How can I do that? The string of ID's from the database would be the haystack, and the ID's from the list would be the needles, and every time one ID from the haystack matches with an ID from the list then that page title should be automatically marked as checked with the help of an if statement. This is how the list gets listed, with a foreach loop: <?php $pages = get_pages(); foreach ($pages as $pagg) { $option = '<input type="checkbox" name="exclude[]" value="'. $pagg->ID .'">'; $option .= $pagg->post_title . "<br />"; echo $option; } ?> Now I need to compare the ID in the value field with the ID string (separated by spaces) in the database row, and when a match occurs then execute a case. I know there are functions like str_replace and similar, but I'm not sure if I can do that with them, what would be a fitting function for my case? Hey all,
maybe someone can help me with this problem:
I am using PHP and i want to extract the red text including the orange text but only between the blue text.
i tried a lot, but i cant find the solution.
This is what i tried: $repattern = '/<td class="program_date">(\s+\S+.+)\s+.+(\s\S.+)<\/a>/i';
The final result should look like this:
Array with following Data inside:
Mo, 09.06.2014
13:45
16:15
Di, 10.06.2014
13:45
Mi, 11.06.2014
13:45
16:15
and so on..
Thanks in advance.
Here is a part from source:
<td class="program_time"> <span class="program_head">Vorstellungen:</span><br /> <table> <tr> <td class="program_date"> Mo, 09.06.2014 </td> <td><a href='http://fmzimst.kinokartenreservierung.at/reservierung.php?id=74380' target="_top">13:45</a> </td> <td><a href='http://fmzimst.kinokartenreservierung.at/reservierung.php?id=74381' target="_top">16:15</a> </td> </tr> <tr> <td class="program_date"> Di, 10.06.2014 </td> <td><a href='http://fmzimst.kinokartenreservierung.at/reservierung.php?id=74384' target="_top">13:45</a> </td> </tr> <tr> <td class="program_date"> Mi, 11.06.2014 </td> <td><a href='http://fmzimst.kinokartenreservierung.at/reservierung.php?id=74388' target="_top">13:45</a> </td> <td><a href='http://fmzimst.kinokartenreservierung.at/reservierung.php?id=74389' target="_top">16:15</a> </td> </tr> <tr> <td class="program_date"> Do, 12.06.2014 </td> <td><a href='http://fmzimst.kinokartenreservierung.at/reservierung.php?id=74392' target="_top">13:45</a> </td> <td><a href='http://fmzimst.kinokartenreservierung.at/reservierung.php?id=74393' target="_top">16:15</a> </td> </tr> </table> </td> Edited by spaxi, 09 June 2014 - 07:24 AM. One email address per line, thousands of lines. I was hoping to just use a text editor to do the work, but I may have to make a php loop to do it.
here's the regex:
^([a-z0-9-_\.]+@[a-z0-9-_]+\.[a-z]{2,3})$
Tested the RegEx, and it works great. It returns thousands of lines of matched email addresses. Problem is, I only want it to find the lines that don't match. How do you make RegEx return unmatched lines?
This topic has been moved to PHP Regex. http://www.phpfreaks.com/forums/index.php?topic=306874.0 Hey Guys, I'm struggling with some logic of how to do something wondering if anyone can point me in the right direction. Details: I am making a PHP/MySQL game to learn more PHP, I've got my login/logout system created. However I am planning on the game been map based on a 100x100 grid. I have two tables: USERS Username, Password, x, y Test, Test, 1, 1 MAP X, Y, type 0,1,1 0,2,1 0,3,2 0,4,3 0,5,2 etc I am stuck on how to get the user's logged in X and Y coordinates and then compare them with the map table X and Y, to see what type of field to show, 1,2 or 3. Is there a name for this type of function so I can do some research on it? Or could someone give me an example? Would be fantastic if anyone has any advice. Thanks in advance NewcastleFan Hi guys I am new here I have had a search around and can't really find out how to do this. Its quite difficult for me to explain and I am really new to PHP / mySQL - just starting out really. I hope to learn from doing small projects like this and seeing how it gets done. So I have a mySQL DB with two different tables - one is called "notesnew" the other is called "users". I have modified a common tutorial on how to make a "to do list" for what I am doing here. Basically users can login and post messages on this list as them self. Each user's post appears as a list item, showing their username, the time they posted the message and the message content. The message content, time and owner of the message is stored in the "notesnew" table. The list of user's, their passwords and their "avatar/profile" image URL location is stored in the "users" table. Now I am having trouble getting each user's avatar image from being output next to each of their posts. The part that is confusing me is being able to match up the username's post with their content that is display - because I am posting the user's name along with their post, based on the logged in "session name" as their username. So basically, all the content being listed is being displayed from the "notesnew" table. I need to somehow figure out what each user's profile image is based on what is stored against their entry in the "users" table. Here is the code I have so far. It is not working properly - it displays all content etc, but displays the avatar / image of the last user that has registered. Can anyone help me out here with some code that works, or pointers to try follow? I know the $finduserprofile part is incorrect in the way it goes through all user's and finds their profileimg, and that the image displayed next to each post is therefore incorrect (as it displays the last member to have registered's avatar, but its just that I don't know how else to do what I am trying to do. Code: [Select] <?php //Connect to the database $connection = mysql_connect('localhost', 'zzzz' , 'zzzzzzz'); $selection = mysql_select_db('zzzzz', $connection); $username = $_COOKIE['ID_my_site']; //Was the form submitted? if($_POST['submit']){ //Map the content that was sent by the form a variable. Not necessary but it keeps things tidy. $content = $_POST['content']; //Insert the content into database $ins = mysql_query("INSERT INTO `notesnew` (content, owner, dp_time) VALUES ('$content', '$username', NOW())"); //Redirect the user back to the members or index page header("Location:index.php"); } /*Doesn't matter if the form has been posted or not, show the latest posts*/ //Find all the notes in the database and order them in a descending order (latest post first). $find = mysql_query("SELECT * FROM `notesnew` ORDER BY id DESC"); $finduserprofile = mysql_query("SELECT * FROM `users` ORDER BY id DESC"); //Setup the un-ordered list echo '<ul>'; while($row = mysql_fetch_array($finduserprofile)) { $imagelocation = $row['profileimg']; //Continue looping through all of them while($row = mysql_fetch_array($find)) { $owner = $row['owner']; //For each one, echo a list item giving a link to the delete page with it's id. echo '<li>' . '<img src ="' . $imagelocation . '">' . $row['owner'] . ' said at ' . $row['dp_time'] . ': ' . $row['content'] . ' <a id="' . $row['id'] . '" href="delete.php?id=' . $row['id'] . '"><img src="delete.png" alt="Delete?" /></a></li>'; } } //End the un-ordered list echo '</ul>'; ?> I have a associative array and I need to compare it to a normal array. Code: [Select] associative will have anywhere from 2-8 of these ['name'] ['color'] ['uid'] Code: [Select] normal array will have anywhere from 1-8 names ['name'] What I need to do is get the name of the people that are in the associative array that are not in the normal array. I've tried all sorts of different loops and what not and I cant seam to get anything to work in every case. Hello Guys, I am trying to figure this out.. I have a page that has several check boxes that when checked the values ends up as an array Like this 1, 3, 9, 6, That's what it looks like in the database. I want to compare the values (numbers) submitted with the values in my database table called benefits Here is the function I wrote this function and I want to check the values of the submitted values but I am just not sure how to compare the values, especially with a comma in the array. Code: [Select] $benefits2 = $_POST['benefits']; function check_benefits ($benefits2,$member_id,$description,$ip){ $queryb = mysql_query("SELECT * FROM benefits WHERE b_id = $benefits2"); while ($row = mysql_fetch_array($queryb)) { $benefit_list = $row['b_id']; } if (isset($benefits2)&&( $benefit_list!== $benefits2)) { Do something here! } } Thanks for your help! So what I'm wanting to do is log changes made by users, to the database... I was thinking on the lines of first doing a query of the database row that is going to be affected, prior to it being affected, putting that row result in an array variable, then allowing the update to happen and re-querying the database row and putting the results in a separate array, to then compare to the original database row array variable... So I guess, (A): Does this make sense to do this, this way? and (B): How do you compare 2 identical arrays, then extract the value from both where the particular element does not match, e.g. has been updated? This topic has been moved to PHP Regex. http://www.phpfreaks.com/forums/index.php?topic=347186.0 I'm going crazy. I have two arrays. The first has working hours and the array is like this: ```array(7) { [0]=> array(4) { ["morning_from"]=> string(6) "closed" ["morning_to"]=> string(6) "closed" ["afternoon_from"]=> string(5) "13:00" ["afternoon_to"]=> string(5) "19:00" }``` The second one is the busy times, the array is like this: ```array(2) { [0]=> { ["title"]=> string(13) "Test" ["start_date"]=> string(19) "2019-11-25 13:00:00" ["end_date"]=> string(19) "2019-11-25 14:00:00" } }```
Now I do a cycle of 15 times because I need to make the list for the next 15 days from today.
``` Unfortunately it does not work as I would like, it does not mark correctly if the date is occupied. I'll post a piece of code:
if($book_i == 0){
$book_day = ucwords(strftime('%d %h', strtotime($book_today_day)));
if(count($getListCalendarStartToday) > $count_list_calendar_p){
$count_more_appointment_on_some_days_morning = 0;
foreach ($getListCalendarStartToday as $key => $value) {
if($day == $book_today_day){ $book_output .= "<li>"; if(isset($user["working_time"]) && $user["working_time"]){ $book_output .= "<div><p>".$book_name_day."</p><p>".$book_day."</p></div>";
if($book_name_day == $lang["days-mon"]){
$book_morning_from = $book_array_working_time[$book_day_int]["morning_from"];
$book_morning_from_hour = (int)substr($book_morning_from, 0, 2);
$book_afternoon_from_hour = (int)substr($book_afternoon_from, 0, 2);
$book_morning_from_hour_duplicated = $book_morning_from_hour;
$book_afternoon_from_hour_duplicated = $book_afternoon_from_hour;
$book_check_closed = 0;
if($book_afternoon_from_hour == 0 && $book_afternoon_to_hour == 0){ $book_output .= "<div>";
for ($n=0; $n < $count_more_appointment_on_some_days_afternoon; $n++) {
$day_appointment_p_start_hour = date('H', strtotime($getListCalendarStartToday[$count_list_calendar_p]["start_date"]));
if($book_afternoon_from_hour_duplicated != $book_afternoon_from_hour){
if($book_afternoon_from_hour != $book_afternoon_to_hour){
$book_afternoon_from_hour_duplicated += 1; if($book_afternoon_from_min == 0){
if($day_appointment_p_start_hour == $day_appointment_p_end_hour){
$count_hour_appointment = 0;
$count_hour_appointment += 1;
$book_afternoon_from_hour_duplicated += $count_hour_appointment; break; }else{ if($book_i == 0){
if($day_appointment_p_start_min >= $book_afternoon_from_min && $day_appointment_p_start_min <= 30){ }else{
if($day_appointment_p_start_min >= $book_afternoon_from_min && $day_appointment_p_start_min >= 30){ }
$book_output .= "<a class='uk-button-book-a-visit-hour' id='a-book-a-visit' data-book-day='".$book_today_day."' data-book-hour='".number_add_leading_0($book_afternoon_from_hour).":00'>".number_add_leading_0($book_afternoon_from_hour).":00</a>"; }else{
$book_afternoon_from_hour_duplicated += 1;
if($book_afternoon_from_min == 0){
if($book_afternoon_from_min == $book_afternoon_to_min){
$book_output .= "</div>";
$book_output .= "</li>"; Hello guys, need some help. Let us say i have an array = 2011 ipad 2011 ipad review 2011 ipad price 2011 ipad design 2011 ipad reviews review 2011 ipad 2011 ipad feature I would like to review all the array elements that contain "review"...So the final array should look like 2011 ipad 2011 ipad price 2011 ipad design 2011 ipad feature Thanks Hi all,
I am using foreach statement to gather records and program levenshtein to detect any misspellings and suggesting the correct words.
The thing is i am unable to convert all those strings into a single array.
After trying to correct this issue so many times, i wonder if it is really possible to convert strings into a single array?
Any input is welcome
|