PHP - Find Minimum In Array Loop Until...
I need help this problem seem too tricky for me right now.
I got an array with decimal numbers and behind it says Yes/No. The min() function works magically and still is able to correctly give me the lowest value. But how do i make a while loop that loops until it pops a value that is lowest and has Yes behind it? For example: Array => ('11,64|No', '209,81|Yes', '533,42|Yes', '27,90|No', '93,01|Yes') So this function should return '93,01|Yes' Similar TutorialsSay i have an array (called $myarray) and it has 10 numbers in it like this... 1 2 4 8 9 10 12 14 15 18 Now in my code, I get a number and lets say for this example it is "5". I need to see if that number is in the array --easy enough using in_array()--, but if it is NOT in the array, I need to find the next available number in the array that is greater than my starting number of 5 (which would be "8" in this example). But what is the best way to find this number (i.e. 8 in this example)? I imagine I need to somehow loop through but i'm not sure which loop is the best to use and i'm generally confusing the hell out of myself (which is frustrating because this is probably rather simple to do ). Can anyone help guide me in the right direction? I'm sure this is possible, but I'm not having any luck. Code: [Select] $array = array("11:23", "12:46", "13:34", "14:34", "14:85"); if (in_array('12', $array)) { echo "yes"; } else { echo "no"; }} Hi all, i have this array $str = array("apple is red", "banana is yellow", "pineaple is tropical fruit", "coconut is also tropical fruit", "grape is violet"); i want to find string "coconut" inside $str and put the whole string "coconut is also tropical fruit" into variable $coconut. can i do this? i don't want to use the this code Code: [Select] <? $coconut = $str[3]; echo "$coconut"; ?> can someone help? Thank you, Best Regards I have a list of products in database and some have the same itemid but a different price depending on size What i want to do i if the itemid has more than one size, take the smallest price and then add the word "From" at the beginning. I've tried using the MIN() function but can't get it to do what i want. If there is only one size it works fine but if there is more than one it just says "From 0.00" Code: [Select] while ($row = $result->fetch()) { if(!isset($items[$row['itemid']])) { $items[$row['itemid']] = $row; } $items[$row['itemid']]['sizes'][$row['size']] = $row['price']; ### CHANGED ### } foreach($items AS $subitem) { list($prodid, $itemid, $item, $size, $description, $shortdesc, $image, $price) = $subitem; //Create field for item name based upon record count if(count($subitem['sizes']) > 1) { /*$item_name_field = "<ul>\n"; foreach($subitem['sizes'] as $size => $price) ### CHANGED ### {*/ //} //$item_name_field .= "<ul>\n"; $myprice = explode(".",number_format(min($subitem['price']),2)); $item_name_field .= "<li>From ".$myprice[0].".".$myprice[1]." {$size}</li>\n"; } else { $myprice = explode(".",number_format($subitem['price'],2)); $item_name_field .= "<li><span class=\"ucprice\">£".$myprice[0]."<?span><span class=\"lcprice\">.".$myprice[1]."</span></li>\n"; } Good Evening, I'm having no luck in something that I'm sure is incredibly simply... If I have an array like the following... Code: [Select] $array = array(15,22,0,43,0,6);How can I find and replace all the zeros with a one? Regards, Ace I need to find the earliest and latest times, but there must be at least 3 to count it. $array[] = "09:00 - 15:00" $array[] = "09:00 - 15:00" $array[] = "09:00 - 15:00" $array[] = "09:00 - 17:00" $array[] = "09:00 - 15:30" $array[] = "07:30 - 15:00" $array[] = "07:00 - 12:00" So the above would return 09:00 - 15:00 I thin would need to ensure that a maximum 4 hours inbetween, so I then get something like 10:00 - 14:00 returned okay I am using a jquery plugin to re-arrange images which are in mysql and they have their own "order_number" ... when i re-arrange stuff the new order is put into a hidden field in a form and i have it along with another hidden field with their current order... when submitted I combine these two fields in an array so the key is the original order and the value is the new order ....i have 12 images... Array ( [1] => 1 [2] => 2 [3] => 3 [4] => 4 [5] => 5 [6] => 6 [7] => 7 [8] => 8 [9] => 9 [10] => 10 [11] => 11 [12] => 12 ) this is what is what the array looks like... i have a foreach loop with a mysql query but things get kind of weird when you try to do it this way $num = $_POST['old_num']; $num = unserialize($num); $sort = $_POST['sortOrder']; $sort = explode(',', $sort); if ($_POST){ $combine = array_combine($num, $sort); foreach($combine as $key => $value){ mysql_query("UPDATE shirts SET order_number='$value' WHERE order_number='$key' ") or die(mysql_error()); } when you do this lets say for example we have the image with order number "1" get switched with the image order number "2"..... the database first updates with number 1 which becomes 2... then when it goes to number "2"... at this point... the first image gets switched back to number 1.... so 1 becomes 2 then the new 2 becomes 1 again and the other 2 becomes 1 also. I can not think of another way I could update mysql with the correct order numbers... If anyone has any ideas or other solutions I am open to all suggestions... thank you! 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> '
;
?>
Hi i need a bit of help. i have toner database which stores, the type, brand, colour, min, max stock. I just want to know if there is anyway of notifying the user when the toner reachs the min level, maybe highligh the row in red or something similar. many thanks. Here's the scenario.... A Customer clicks on a product on the product page, this will open up the page for the individual product. In this example, it's a shirt. The shirt is available in many sizes and colors. The Minimum QTY for this product is : 12 . The customer can select as many sizes and colors as they want, as long they select a total of 12 (all sizes + all colors = total). After making their selections for this shirt, there is an "Add to Cart" button. I would like to run a check to make sure that the total is equal to or greater than the minimum QTY. Here is the form : Code: [Select] <?php session_start(); require("db.php"); require("functions.php"); $validid = pf_validate_number($_GET['id'], "redirect", $config_basedir); $prodsql = "SELECT * FROM products WHERE id = " . $_GET['id'] . ";"; $prodres = mysql_query($prodsql); $numrows = mysql_num_rows($prodres); $prodrow = mysql_fetch_assoc($prodres); $prodcatsql = "SELECT * FROM categories WHERE id = " . $_GET['id'] . ";"; $prodcatres = mysql_query($prodcatsql); $bulkcat = mysql_num_rows($prodcatres); if($numrows == 0) { header("Location: " . $config_basedir); } else { if($_POST['submit']) { if(!$_SESSION['SESS_ORDERNUM']) { if($_SESSION['SESS_LOGGEDIN']) { $sql = "INSERT INTO orders(customer_id, registered, date) VALUES(" . $_SESSION['SESS_USERID'] . ", 1, NOW())"; mysql_query($sql); session_register("SESS_ORDERNUM"); $_SESSION['SESS_ORDERNUM'] = mysql_insert_id(); } else { $sql = "INSERT INTO orders(registered, date, session) VALUES(0, NOW(), '" . session_id() . "')"; mysql_query($sql); session_register("SESS_ORDERNUM"); $_SESSION['SESS_ORDERNUM'] = mysql_insert_id(); } } foreach ($_POST as $name => $value) { if (substr($name, 0, 4) == 'qty_' && $value != '' && is_numeric($value)) { $arrOptions = explode('_', $name); $sizeid = $arrOptions[1]; $colorid = $arrOptions[2]; $quantity = $value; $itemsql = "INSERT INTO orderitems(order_id, product_id, size_id, color_id, quantity) VALUES (" . $_SESSION['SESS_ORDERNUM'] . ", " . $_GET['id'] . ", " . $sizeid . ", " . $colorid . ", " . $quantity . ")"; mysql_query($itemsql); } } $totalprice = $prodrow['price'] * $_POST['amountBox'] ; $updsql = "UPDATE orders SET total = total + " . $totalprice . " WHERE id = " . $_SESSION['SESS_ORDERNUM'] . ";"; mysql_query($updres); header("Location: " . $config_basedir . "showcart.php"); } else { require("header.php"); echo "<div id='adminhome'>"; echo "<form action='addtobasket.php?id=" . $_GET['id'] . "' method='POST'>"; echo "<table cellpadding='10' border='0'>"; echo "<tr>"; if(empty($prodrow['image2'])) { echo "<td width='205'><img src='store-images/no-image-large.jpg' width='200' alt='" . $prodrow['name'] . "'>"; } else { echo "<td width='205'> <img src='store-images/" . $prodrow['image2'] . "' width='200' alt='" . $prodrow['name'] . "'>"; } echo "</td>"; echo "<td>"; echo "<h1>";echo $prodrow['name'];echo "</h1>"; echo "<h2>";echo $prodrow['description'];echo "</h2>"; //echo "<pre>" . wordwrap( $prodrow['description'] , 30 ) . "</pre>"; echo "<p>";echo $prodrow['details'];echo "</p>"; echo "<br>"; if($bulkcat==0) { echo "<div id='bulk1'>"; echo "<table cellpadding='2' border='0'>"; echo "<tr>"; echo "<td>Quantity</td>"; echo "<td>12</td>"; echo "<td>24+</td>"; echo "<td>48+</td>"; echo "</tr>"; echo "<tr>"; echo "<td>Price</td>"; echo "<td>$" . money_format('%i', $prodrow['price']) . "</td>"; echo "<td>$" . money_format('%i', $prodrow['price2']) . "</td>"; echo "<td>$" . money_format('%i', $prodrow['price3']) . "</td>"; echo "</tr>"; echo "</table>"; echo "</div>"; echo "<div id='bulk2'>"; echo "<table cellpadding='2' border='0'>"; echo "<tr>"; echo "<br><div align='center'><strong>For Sizes 2XL - 5XL</strong></div>"; echo "</tr>"; echo "<tr>"; echo "<td>Quantity</td>"; echo "<td>12</td>"; echo "<td>24+</td>"; echo "<td>48+</td>"; echo "</tr>"; echo "<tr>"; echo "<td>Price</td>"; echo "<td>$" . money_format('%i', $prodrow['price4']) . "</td>"; echo "<td>$" . money_format('%i', $prodrow['price5']) . "</td>"; echo "<td>$" . money_format('%i', $prodrow['price6']) . "</td>"; echo "</tr>"; echo "</table>"; echo "</div>"; } else { echo "<div id='bulk1'>"; echo "<table cellpadding='2' border='0'>"; echo "<tr>"; echo "<td>Quantity</td>"; echo "<td>12</td>"; echo "<td>24+</td>"; echo "<td>48+</td>"; echo "</tr>"; echo "<tr>"; echo "<td>Price</td>"; echo "<td>$" . money_format('%i', $prodrow['price']) . "</td>"; echo "<td>$" . money_format('%i', $prodrow['price2']) . "</td>"; echo "<td>$" . money_format('%i', $prodrow['price3']) . "</td>"; echo "</tr>"; echo "</table>"; echo "</div>"; } echo "</td>"; echo "</tr>"; echo "</table>"; echo '<div id="basketmatrix">'; echo '<table cellpadding="1" border="1">'; echo '<tr>'; echo '<td></td>'; $arrsizes = array(); $i = 0; $result = mysql_query("SELECT DISTINCT s.id, s.size FROM sizes s INNER JOIN productoptions p ON s.id = p.sizeid WHERE p.productid = '" . $_GET['id'] . "' ORDER BY s.id"); while ($row = mysql_fetch_assoc($result)) { echo '<td class="heading">' . $row['size'] . '</td>'; $arrsizes[$i] = $row['id']; $i++; } echo '</tr>'; $i = 0; $result = mysql_query("SELECT DISTINCT c.id, c.color FROM colors c INNER JOIN productoptions p ON c.id = p.colorid WHERE p.productid = '" . $_GET['id'] . "' ORDER BY c.id"); while ($row = mysql_fetch_assoc($result)) { echo '<tr>'; echo '<td class="heading">' . $row['color'] . '</td>'; foreach ($arrsizes as $sizevalue) { echo '<td><input type="text" name="qty_' . $sizevalue . '_' . $row['id'] . '" size="5" /></td>'; } echo '</tr>'; } echo '</table>'; echo '</div>'; echo "<br>"; echo "<br>"; echo '<table>'; echo '<tr>'; echo '<td>'; echo '<p>You MUST order a total of <font color="#ff0000"><strong>(' . $prodrow['minimum'] . ')</strong></font> or more to add this item to your cart.<br>'; echo '(all colors + all sizes = total)</p>'; echo '</td>'; echo '<tr>'; echo '<td>'; echo"<input type='submit' name='submit' value='Add To Cart'>"; echo '</td>'; echo '</tr>'; echo '</table>'; echo "</form>"; echo "</div>"; } } require("footer.php"); ?> Hello everyone! I am new here and this is my first post. I have been a member at another forum which they tend to make fun of newbies instead of helping them learn. That is why I am here Below is my script that allows me to upload 6 images at once and this works nicely. However, I am trying to change the variable $newname to increment in each pass so that I can build some if statements for my sql query. I would like the variable to start from $newname1 and should end up with 6 of them with the last being $newname6. That way I can have 6 unique picture variables that I can either update or insert into my table. Any help here would be great! Code: [Select] $upload_image_limit = 6; // How many images you want to upload at once? define('MAX_SIZE', '100'); define('UPLOAD_DIRECTORY', '../memberYard'); // Define a list of extensions we want to allow. $allowable = array('.gif', '.jpg', '.jpeg', '.png'); $errors = array(); if (isset($_POST['Submit'])) { if (!empty($_FILES)) { foreach ($_FILES as $file) { // No need for a separate function to get a file's extension $extension = substr($file['name'], strpos($file['name'], ".")); $size = filesize($file['tmp_name']); // Check if the file's extension is in the permissable list if (!in_array(strtolower($extension), $allowable)) { $errors[] = "File {$file['name']} is of an unknown type."; continue; } // Check that the file size is OK if ($size > MAX_SIZE * 1024) { $errors[] = "File {$file['name']} is too big."; continue; } // Generate a random name for the file and move it $newname = substr(md5(microtime()), 0, 12) . $extension; $copied = move_uploaded_file($file['tmp_name'], UPLOAD_DIRECTORY . DIRECTORY_SEPARATOR . $newname); if ($copied === FALSE) { $errors[] = "File {$file['name']} could not be uploaded."; } } } } ?> <div id="mainWrapper"> <div id="main"> <div class="top_bg"></div> <div class="description_pane"> <h2>Upload More Photos</h2> <?php if (!empty($errors)) { echo "<ul>"; foreach ($errors as $error) { echo "<li>{$error}</li>"; } echo "</ul>"; } ############################### HTML FORM while($i++ < $upload_image_limit){ $form_img .= '<label>Image '.$i.': </label> <input type="file" name="image'.$i.'"><br /><br />'; } $htmo .= ' <form method="post" action="" enctype="multipart/form-data"> '.$form_img.' <br /> <input type="submit" value="Upload Images" name="Submit" style="margin-left: 50px;" /> </form> '; echo $htmo; ?> <br /> </div> </div><!--end main --> <div class="main_bottom"></div> </div><!--end mainWrapper --> <? include '../templates/footer.php'; ?> i have an array in the loop but it isn't building up with results. i want it to check if the array exists, if not then create the array. Then in next loop it pushes a new value into the array. Below isn't working?... Code: [Select] while($row=mysql_fetch_assoc($get)); { $key = $row['keyword']; $scope= $_SESSION['scope']; if (!is_array($scope)) { $scopenew = array($key); $_SESSION['scope'] = $scopenew; } else { $scopenew = array_push($scope, $key); $_SESSION['scope'] = $scopenew; } } How can I loop an array and process in groups 100 at a time? I am working with wordpress. I am using a plugin that gets options stored in an array in the database. This is how I get the options Code: [Select] $options = get_option('option_tree'); echo $options['exc_cat']; the exc_cat is a key that stores a set of values. Right now with the code above, it echoes Array. If I do this Code: [Select] echo $options['exc_cat'][0]; it returns 5. Which is what I would expect it to do. What I can't figure out is how to get it to store each value which should be a number into 1 variable. What I need to do is loop through each value that is stored in the exc_cat key, return the number seperated by a -1,. So the result should look like this -1, -5 1 and 5 should be the only two numbers stored in the array at this point. Can you help? Thanks Hello, I'm trying to loop out the following value from the below array and cannot figure it out - orders.orderid Could anyone help me? stdClass Object ( [recsindb] => 4320 [recsonpage] => 10 [9] => stdClass Object ( [orders.orderid] => 83269442 ) [8] => stdClass Object ( [orders.orderid] => 83267681 ) )
echo "<pre>"; How do i do if i've reached of array? i know i could do end of loop. but the array is present many times in my code. Code: [Select] while($row = mysql_fetch_assoc($getdetails)) { $people = $row['people']; $_SESSION['people'][] = $people; if(end($_SESSION['people'])) { //code } } I have following in a csv file: sku,quantity,price ---------------------- ML2225-1/4,10,38.77 ML2225-1/4,20,36 ML2225-1/4,30,33.23 ML2225-5/16,10,35.94 ML2225-5/16,20,33.37 ML2225-5/16,30,30.8 ML2225-3/8,10,34.37 ML2225-3/8,20,31.92 ML2225-3/8,30,29.46 ML2225-7/16,10,34.37 ML2225-7/16,20,31.92 ML2225-7/16,30,29.46 ML2225-1/2,10,34.37 ML2225-1/2,20,31.92 ML2225-1/2,30,29.46 ... I am able to read the file (fgetcsv). How do I build an array for each unique sku set, then do something, then continue to the next unique sku set? Thanks, Mike Code: [Select] // Get the users armour names $user_armour = array($user_head, $user_upper, $user_hands, $user_lower, $user_feet); $i=0; while($i < count($user_armour)) { $query1="SELECT * FROM armour WHERE id='$user_armour[$i]'"; $result1=mysql_query($query1); $array1=mysql_fetch_array($result1); $armour_name[$i]=$array1["name"]; $i++; } // set the users armours name $user_prot = array($user_head, $user_upper, $user_hands, $user_lower, $user_feet); // Get the users overall protection $i=0; while($i < count($user_prot)) { $query1="SELECT * FROM armour WHERE id='$user_prot[$i]'"; $result1=mysql_query($query1); $array1=mysql_fetch_array($result1); $armour_prot[$i]=$array1["protection"]; $i++; } // set the users protection $user_protection=$armour_prot[0] + $armour_prot[1] + $armour_prot[2] + $armour_prot[3] + $armour_prot[4]; Is there a way to get them as one so: Code: [Select] $user_armour = array($user_head, $user_upper, $user_hands, $user_lower, $user_feet); $i=0; while($i < count($user_armour)) { $query1="SELECT * FROM armour WHERE id='$user_armour[$i]'"; $result1=mysql_query($query1); $array1=mysql_fetch_array($result1); $armour_name[$i]=$array1["name"]; $armour_prot[$i]=$array1["protection"]; $i++; } // set the users armours name $user_prot = array($user_head, $user_upper, $user_hands, $user_lower, $user_feet); Will that work and if so how would you then get the 2 different values out of say "$user_prot[0]". Cheers guys, Ruddy Hi I am trying to tidy up a bit of php code to make the end display much better but I am a bit stuck, I have the following code which takes a mysql query and uses the result to create a google graph. <?php $str = ""; $str .= "<img src='http://chart.apis.google.com/chart?chs=600x300"; $str .= "&chd=t:"; $i=0; while($row_Recordset3 = mysql_fetch_assoc($Recordset3)){ $reading_array[$i] = $row_Recordset3['reading']; $date_array[$i] = date("j/n", strtotime($row_Recordset3['date'])); $i ++; } $count=0; $count = count($reading_array); if($count>1) { $rstring = implode(",", (array_reverse($reading_array))); $dstring = implode("|", (array_reverse($date_array))); }else{ echo $count; } $str = $str.$rstring; $str = $str."&cht=lc&chxl=0:|"; // We will close the src attribute with \' and to print escape character ' we shall precede it with \ $str = $str.$dstring; $str = $str."&chxt=x,y&chds=0,25&chxr=1,0,25,5&chm=o,0044FF,0,-1,8|b,3399CC44,0,1,0&chtt=Electricity Generation for the last 35 days'"; $str = $str." >"; //we shall echo the $str that will display the graph ?> <tr><td> <?php echo $str; ?> Currently the result is http://chart.apis.google.com/chart?chs=600x300&chd=t:10,6,1,11,12,7,6,2,1,1,4,10,1,5,12,3,3,6,1,6,3,3,1,5,3,1,1,6,8,5,8,8&cht=lc&chxl=0:|27/10|28/10|29/10|30/10|31/10|1/11|2/11|3/11|4/11|5/11|6/11|7/11|8/11|9/11|10/11|11/11|12/11|13/11|14/11|15/11|16/11|17/11|18/11|19/11|20/11|21/11|22/11|23/11|24/11|25/11|26/11|27/11&chxt=x,y&chds=0,25&chxr=1,0,25,5&chm=o,0044FF,0,-1,8|b,3399CC44,0,1,0&chtt=Electricity%20Generation%20for%20the%20last%2035%20days I need to make it display only every 7 dates so that they are readable but I still need the pipes in between to space out the dates correctly so they tie in with the correct point on the graph, like this where I manually removed some dates as a demo http://chart.apis.google.com/chart?chs=600x300&chd=t:10,6,1,11,12,7,6,2,1,1,4,10,1,5,12,3,3,6,1,6,3,3,1,5,3,1,1,6,8,5,8,8&cht=lc&chxl=0:|27/10|||||1/11|||||6/11|7/11|8/11|9/11|10/11|11/11|12/11|13/11|14/11|15/11|16/11|17/11|18/11|19/11|20/11|21/11|22/11|23/11|24/11|25/11|26/11|27/11&chxt=x,y&chds=0,25&chxr=1,0,25,5&chm=o,0044FF,0,-1,8|b,3399CC44,0,1,0&chtt=Electricity%20Generation%20for%20the%20last%2035%20days This is beyond my limited stills, can anyone help please? Thanks Gordon i have 2 arrays... first array of lastnames, second array of firstnames lastAry = array('smith', 'jones', 'reed', 'chan') firstAry = array('mary', 'chris', 'kim', joe', 'sara', 'tim', 'amy', 'fred') how do i loop through each lastnames and turn into a string with firstname so it looks like : smith | mary | chris jones | kim | joe reed | sara | tim chan | amy | fred |