Psycho
Moderators-
Posts
12,157 -
Joined
-
Last visited
-
Days Won
129
Everything posted by Psycho
-
That will return the text after the first instance of a string. The OP wants the text after the last occurance (or 2nd to last) of a string: function lastPath($fullPath) { $fullPath = (substr($fullPath, -1) == '/')?substr($fullPath, 0, -1):$fullPath; return substr(strrchr($fullPath, '/'), 1); } $text = "http://omgGoogle.com/member/4333/"; echo lastPath($text); // 4333
-
Yea, I complete missed that, however I was sort of on They still would cause problems. Yes, I agree. If you leave the default values in there are going to be a lot of submissions with the email address "example@domain.com". At the very least the validation should check for the default values and treat them as errors. I'd also suggest an option at the top of the select list such as "--Select One--" with an empty value to force the user to select the appropriate value. By the way, the "smack yourself i nthe forehead" was meant for the OP, not you.
-
It's not the default values. Remove them and it still does not trigger the errors. Time to smack yourself in the forehead. Don't worry, we all do it. Your submit button has a name of "button" <input type="submit" name="button" id="button" value="Submit" /> But, you are testing for a POST item with the name "submit" if ( isset ($_POST['submit'])) { So your page never checks the form data. Either change the name of the submit button or the variable you are testing for. You don't have to check for a particular post value either - just check that $_POST was set if ( isset ($_POST)) { I would also look at revising your error handling to re-populat the fields with any values the user did enter.
-
[SOLVED] Not really a problem, but rather a question.
Psycho replied to jrws's topic in PHP Coding Help
Had some minor errors that I found. Here is updated code <?php $date = time(); $month = date('m', $date) + 2; $year = date('y', $date); $title = date('F', $date); $days_in_month = cal_days_in_month(0, $month, $year); //Start the table echo "<table border=\"6\" width=\"394\">\n"; echo " <tr><th colspan=\"7\">{$title} {$year}</th></tr>\n"; echo " <tr>\n"; echo " <th width=\"62\">Su</th><th width=\"62\">M</th><th width=\"62\">Tu</th>\n"; echo " <th width=\"62\">W</th><th width=\"62\">Th</th><th width=\"62\">F</th><th width=\"62\">Sa</th>\n"; echo " </tr>\n"; //Create empty days as needed for beginning of month for ($empty=0; $empty<(date('N', mktime(0, 0, 0, $month, 1, $year))%7); $empty++) { if ($empty == 0) { echo "<tr>\n"; } echo " <td></td>\n"; } //Create the days of the month for ($day=1; $day<=$days_in_month; $day++) { $dow = date('N', mktime(0, 0, 0, $month, $day, $year)) % 7; //Open row if first day of week if ($dow == 0) { echo " <tr>\n"; } $style = ($day==date('d', $date)) ? ' style="background-color:#00ff00;"' : ''; echo " <td style=\"text-align:center\"{$style}>{$day}</td>\n"; //Close row if last day of week if ($dow == 6) { echo " </tr>\n"; } } //Create empty days as needed for end of month for ($dow; $dow<6; $dow++) { echo " <td></td>\n"; if ($dow == 5) { echo " </tr>\n"; } } //Close the table echo "</table>\n"; ?> -
[SOLVED] Not really a problem, but rather a question.
Psycho replied to jrws's topic in PHP Coding Help
The code below sets a style for the current day. Also reduced the amount of code needed and corrected some minor issues (e.g. creating a 'blank' row if the month ends on a saturday). <?php $date = time(); $day = date('d', $date); $month = date('m', $date); $year = date('y', $date); $title = date('F', $date); $first_day = mktime(0, 0, 0, $month, 1, $year); $day_of_week = date('N', $first_day); $days_in_month = cal_days_in_month(0, $month, $year); //Counter for the weekday position $day_count = 1; //Start the table echo "<table border=\"6\" width=\"394\">\n"; echo "<tr><th colspan=\"7\">{$title} {$year}</th></tr>\n"; echo "<tr><th width=\"62\">Su</th><th width=\"62\">M</th><th width=\"62\">Tu</th><th width=\"62\">W</th><th width=\"62\">Th</th><th width=\"62\">F</th><th width=\"62\">Sa</th></tr>\n"; echo "<tr>\n"; //Create empty days as needed for beginning of month while ($day_count <= $day_of_week) { echo "<td></td>\n"; $blank -= 1; $day_count++; } //Create the days of the month for ($day_num=1; $day_num<=$days_in_month; $day_num++) { //Open row if first day of week if ($day_count==1) { echo "<tr>\n"; } $style = ($day_num==$day) ? ' style="background-color:#00ff00;"' : ''; echo "<td style=\"text-align:center\"{$style}>{$day_num}</td>\n"; $day_count++; //Close row if last day of week if ($day_count > 7) { echo "</tr>\n"; $day_count = 1; } } //Create empty days as needed for end of month if ($day_count>1) { for($day_count; $day_count<=7; $day_count++) { echo "<td></td>\n"; } echo "</tr>\n"; } //Close the table echo "</table>\n"; ?> -
<html> <head> <script type="text/javascript"> function UpdateCost() { var sum = 0; var elem; var i = 0; while (document.getElementById('game'+i)) { elem = document.getElementById('game'+i); if (elem.type=='checkbox') { sum += (elem.checked) ? Number(elem.value) : 0; } else if (elem.type=='select-one') { sum += Number(elem.options[elem.selectedIndex].value); } i++; } document.getElementById('totalcost').value = sum.toFixed(2); } // </script> </head> <body> <input type="checkbox" id='game0' value="9.99" onclick="UpdateCost()"> Game 1 ( 9.99)<br> <input type="checkbox" id='game1' value="19.99" onclick="UpdateCost()"> Game 2 (19.99)<br> <input type="checkbox" id='game2' value="27.50" onclick="UpdateCost()"> Game 3 (27.50)<br> <input type="checkbox" id='game3' value="45.65" onclick="UpdateCost()"> Game 4 (45.65)<br> <input type="checkbox" id='game4' value="87.20" onclick="UpdateCost()"> Game 5 (87.20)<br> Game 6 <select name="" id="game5" onchange="UpdateCost()"> <option value="0">0</option> <option value="9.99">1 (9.99)</option> <option value="19.98">2 (19.98)</option> <option value="29.97">3 (29.97)</option> </select><br> Total <input type="text" id="totalcost" value=""> </body> </html>
-
I remember trying to do the same thing ago a long time back. Forget what I did then, but one workaround would be to use two separate fields and use the display property to make it look like it's changing to a password field. function showPW() { document.getElementById('pwText').style.display = 'none'; pwField = document.getElementById('pwPWord'); pwField.style.display = ''; pwField.focus(); pwField.select(); } <input id="pwText" type="text" onfocus="showPW();" value="Password" /><input id="pwPWord" type="password" value="Password" style="display:none;" />
-
Trying to get to the bottom of a paging problem
Psycho replied to slaterino's topic in PHP Coding Help
$maxPage is only set once here $maxPage = ceil($numrows/$rowsPerPage); So it is based upon that evaluated value. $rowsPerPage is hard-coded at the top of the page to a value of 7 and is not changed. So, the problem is obviously with $numrows. So, let's look at how it is set. $result = mysql_query("SELECT COUNT(Product_ID) AS numrows, $catalogue_query GROUP BY Product_ID") or die('Error, query failed'); $row = mysql_fetch_array($result, MYSQL_ASSOC); $numrows = $row['numrows']; I am sure that $numrows is between 1 and 7 - which would result in $maxPage set to 1. But, the query doesn't make sense to me for a pagination script. If you have many proudct IDs in that table and some are duplicated then that query would return a result set with a count for each group of IDs. I *think* what you really want is just the number of records - not the counts for the grouped records (since your diplay query is not grouping records). Your count query should be identical to the one you run to get the records without the LIMIT. Try this: $result = mysql_query("SELECT $catalogue_query") or die('Error, query failed'); $numrows = mysql_num_rows($result); EDIT: I changed the above after a second look at your code. It looks as if you should be counting ALL the records, not just the unique IDs -
Set hidden checkbox on parent from child window
Psycho replied to Yesideez's topic in Javascript Help
Yes, the value should be the logical true or false values (no quotes). Also, "getElementById()" is not written correctly - the "B" should be capitalized. But, since you are dealing with a popup, just using top.document won't work. This is what I understand: There is a parent window There is a child window that was opened from the parent. That child window has frames In one frame of the child window there is a checkbox that you want to affect a checkbox in the parent window This is interesting. You need to traverse up to the "top" of the popup window and then over to the "parent" I tested this and it works (where 'pc' is the id of the "parent checkbox"): <input type="checkbox" onclick="top.opener.document.getElementById('pc').checked=this.checked;"> Here are my test files for reference: (parent.htm) <html> <body> <a href="child.htm" target="_blank">Open Child</a><br><br> <input type="checkbox" name="pc" id="pc" value="x"> Checkbox </body> </html> (child.htm) <HTML> <FRAMESET ROWS="10%,*"> <FRAME SRC="frame.htm"> <FRAME SRC="http://www.yahoo.com"> </FRAMESET> </HTML> (frame.htm) <html> <body> <input type="checkbox" value="1" onclick="top.opener.document.getElementById('pc').checked=this.checked;"> One<br> </body> </html> -
Can you state what problems there are? I wrote my code off the cuff and was not able to test even for syntax errors. But the logic should be sound. I did notice that I had the wrong check on the last IF statement. Should have been if(mkdir($full_path))
-
The problem is pretty obvious while (mysql_numrows(mysql_query($query))) { $count++; $amber_dir_new=$amber_dir.$amber_dir_suffix.$underscore.$count; } Aside from the fact that it should be mysql_num_rows(), the condition never changes, so the loop will continue indefinitely. $amber_dir_new is the only thing changed within the loop, but it is not part of the condition, $query is. If $query was changing records in the db it might be used to exit the loops, but it is only doing a select. In this instance you would need to modify $query to have the loop exit. while (mysql_num_rows(mysql_query($query))) { $count++; $amber_dir_new=$amber_dir.$amber_dir_suffix.$underscore.$count; $query="select id from jobs where workdir='$amber_dir_new' and owner='$user_id'"; } But, there are better ways to handle this than running multiple queries. Try this: $amber_dir_suffix = '_amber'; $amber_dir_new = $amber_dir.$amber_dir_suffix; $query="SELECT workdir FROM jobs WHERE workdir LIKE '$amber_dir_new%' AND owner='$user_id'"; $result - mysql_query($query) or die (mysql_error()); $directories = array(); while ($record = mysql_fetch_assoc($result)) { $directories[] = $record['workdir']; } if (in_array($amber_dir_new, $directories)) { $i = 0; do { $amber_dir_new = "{$amber_dir}{$amber_dir_suffix}_{$i}"; $i++; } while (in_array($amber_dir_new, $directories)); } $full_path = "{$home_dir}/{$user_dir}/Xplor-SC/{$amber_dir_new}/"; if(!mkdir($full_path)) { echo "Directory $amber_dir_new created succesfully "; } else { echo "Cannot create dir $home_dir/$user_dir/Xplor-SC/$amber_dir_new!"; }
-
Or do you want them displayed like this? | Name: | Name1 | Name2 | Name3 | | Date: | Date1 | Date2 | Date3 | | Description: | Descr1 | Descr2 | Descr3 | | Image: | Image1 | Image2 | Image3 | <?php //Query the DB $query = "SELECT * FROM table"; $result = mysql_query($query) or die(mysql_error()); //Populate results into an array while($row = mysql_fetch_assoc($result)) { $result_ary['Name'][] = $row['name']; $result_ary['Date'][] = $row['date']; $result_ary['Description'][] = $row['description']; $result_ary['Image'][] = $row['image']; } //Populate table horizontally echo "<table border='1'>\n"; foreach($result_ary as $field_name => $field_values) { echo "<tr>\n"; echo "<th>{$field_name}</th>"; foreach($field_values as $value) { echo "<td>{$value}</td>"; } echo "</tr>\n"; } echo "</table>"; ?>
-
<?php $sql = "SELECT * FROM tblsubscribeddetails order by intSubID"; $result = mysql_query($sql); while ($row = mysql_fetch_array($result)) { $email[] = $row['email']; } echo implode(',', $email); ?>
-
Also, you are running the exact same query in three different places. You should design your code better so you are not duplicating so much. Otherwise, debuggin will become more difficult (e.g. fix a bug in one place and not another). The code below should do the exact same thing without all the unnecessary repetition (no guarantees). however, I think there is a bug in your logic. Total Cose is being saves as a session variable (for multiple items) and it get ADD to when the page runs. So, if you had one item the total cose would be (1 * the price of the item). Then if that item was added again it would calculate the total cose as Total Cost + (2 * price of the item). So you would have 3*the item price instead of 1* the item price. At least that's the way it looked to me from the code you posted. I made a modification for that in the code below. <?php if(isset($_GET['clearlist'])) { session_destroy(); } else { $item_to_add = $_GET['item']; $query = mysql_query("SELECT * FROM hrhuntitems WHERE item_name='$item_to_add'") or die(mysql_error()); while($getitemprice=mysql_fetch_array($query)) { $costofitem = $getitemprice['item_price']; } if ( ! isset($_SESSION['items'][$item_to_add] ) ) { $_SESSION['items'][$item_to_add] = 0; $_SESSION['totalcost'] = 0; } $_SESSION['items'][$item_to_add]++; $_SESSION['totalcost'] += $costofitem; if ( isset ( $_SESSION['items'] ) ) { echo "<table> <tr><td><b>Item Name</b></td><td><b>Quanity</b></td></tr>"; foreach($_SESSION['items'] AS $key => $qty) { echo "<tr><td>".$key . "</td><td>" . $qty ."</td></tr>"; } echo "</table>"; echo "<div id=\"totalcost\">Total Cost:" . $_SESSION['totalcost'] ."</div>"; } else { echo "No Items exist!"; } } ?>
-
Use the media property within CSS and create a class (or classes) for elements you don't want displayed in the print. I've never really seen a good tutorial on this - there are different ways to implement. But a google search will generate some resources for more info. Here's an example. <html> <head> <style> @media print { .noPrint { display: none; } } </style> </head> <body> This will display on screen and in print<br> <span class="noPrint">This will display only on screen</span> </body> </html>
-
I've never seen a value passed to innerHTML in that manner (i.e. within parens). Try this: scheduleCell.innerHTML = month+" "+day;
-
Agreed. I was being lazy and just used the query provided by someone in a previous post. It's not that it doesn't belong here. But it is much more appreciated when someone shows they made the effort. Especially when a solution is provided and then the OP changes the parameters to what they really wanted. If you had posted the attempt you made at modifying the code it would have shown that you were taking some initiative. In any event, I hope you have what you need now.
-
I agree. But in this instance, even the current solution - which is not AJAX - requires JavaScript. So, a non-JS solution would require a submit button to be used whenever the select option is changed. It can be a little kludgy, but not a lot of elegant, non-JS options for this type of functinality.
-
This forum is to "help" people with problems and advance their knowledge, not to do it all for you. The code provided would be simple to modify. Did you even try to modify it for your needs? You state that you need the data in an array, but your example shows the data in a delimited string. Which is it? Assuming the second: <?php $query = "SELECT * FROM favorites JOIN songs USING (song_id) WHERE user_name = '$user_name'"; $result = mysql_query($query) or die(mysql_error()); while($record = mysql_fetch_assoc($result)) { $titles[] = $record['song_title']; $artists[] = $record['artist']; $years[] = $record['year']; } $output = '&song_title=' . implode('|', $titles) . '|'; $output .= '&artist=' . implode('|', $artists) . '|'; $output .= '&year=' . implode('|', $years) . '|'; ?>
-
Well, you don't need to use AJAX - although it would be a more elegant solution. When the page is submitted, you need the PHP code to get the value of the selected state and in addition to using it to determine the list of cities, also use it to default the appropriate selection in the state list. <form action="findrestaurants.php" method="POST"> <select NAME="stateList" onChange="this.form.submit()"> <option>Please Select a State</option> <?php //Make a connection to the server... connect("servername","username","password") $link=mysql_connect("localhost","$database","$pass") or die("No server connection".mysql_error()); //connect to our database $db=mysql_select_db("tyzangme_clickndine") or die("No Database Connection ".mysql_error()); //construct a SQL query that shows all hotels in the city $query="SELECT * FROM states"; //run the query $result=mysql_query($query); //for each row returned by our query, do what is in curly braces while($row = mysql_fetch_array($result)) { //Print out each "<option> with the proper values $selected = ($_POST['stateList']==$row['state_ID']) ? ' selected="selected"' : ''; print "<option value=\"{$row['state_ID']}\"$selected>{$row['state_name']}</option>"; } //close the connection mysql_close($link); ?> </select> </form>
-
I'm not following what you are trying to do, but I think I see the problem. In the last code you posted: 1 <?php 2 header('Content-Type: text/plain'); 3 4 $hours = array(); 5 6 for ($a=0; $a < 35; $a++) { 7 $hours[$a] = array(); 8 9 for ($b=0; $b < 6; $b++) { 10 11 if($a < 0){ 12 $previous = $a - 1; 13 14 if($hours[$previous] > 5){ 15 $seconds = mt_rand(1, 5); 16 }else{ 17 $seconds = mt_rand(1, 10); 18 } 19 }else{ 20 $seconds = mt_rand(1, 10); 21 } 22 $hours[$a][$b] = '0:0:'.$seconds; 23 } 24 25 echo (implode("\t", $hours[$a]))."\n"; 26 } 27 ?> Line 6 sets the value of $a from 0 to 34. On line 11 you have a test to see if ($a <0). That condition will never be true, so the else statement (Line 20) is always run.
-
For the love of all that is good and wholesome in the world - DO NOT USE LOOPING QUERIES!!! It is horribly inefficient and uses tons of system resources. The whole point of a "relational" database is that the records are related between tables and you can simply do a JOIN. btherl gave you the perfect , single query to get the data you want (no loops!). As btherl tried to point out (but messed up the link) mysql_fetch_row() returns records as an enumerated array (i.e. $row[0], $row[1], etc.) You need to use mysql_fetch_assoc(); Try this (not tested) $query = "SELECT * FROM favorites JOIN songs USING (song_id) WHERE user_name = '$user_name'"; $result = mysql_query($query) or die(mysql_error()); echo "<table border=\"1\">\n"; echo "<tr><th>Title</th><th>Artist</th><th>Year</th></tr>\n"; while($record = mysql_fetch_assoc($result)) { echo "</tr>\n"; echo "<th>{$record['song_title']}</th>\n"; echo "<th>{$record['artist']}</th>\n"; echo "<th>{$record['year']}</th>\n"; echo "</tr>\n"; } echo "</table>";
-
There were several problems - the arrays and the code you modified. Here is the corrected code: <script type="text/javascript"> // country lists var country = new Array(); country['NorthAmerica'] = ['Canada']; country['Europe'] = ['Swiss']; country['Asia'] = ['China']; // State lists var states = new Array(); states['NorthAmerica'] = new Array(); states['NorthAmerica']['Canada'] = ['Alberta','British Columbia','Ontario']; states['Europe'] = new Array(); states['Europe']['Swiss'] = ['Test']; states['Asia'] = new Array(); states['Asia']['China'] = ['ChineseProvince1']; // City lists var cities = new Array(); cities['NorthAmerica'] = new Array(); cities['NorthAmerica']['Canada'] = new Array(); cities['NorthAmerica']['Canada']['Alberta'] = ['Edmonton','Calgary']; cities['NorthAmerica']['Canada']['British Columbia'] = ['Victoria','Vancouver']; cities['NorthAmerica']['Canada']['Ontario'] = ['Toronto','Hamilton']; cities['Europe'] = new Array(); cities['Europe']['Swiss'] = new Array(); cities['Europe']['Swiss']['Test'] = ['Zurich']; cities['Asia'] = new Array(); cities['Asia']['China'] = new Array(); cities['Asia']['China']['ChineseProvince1'] = ['Los Angeles','San Francisco']; function setCountry() { contSel = document.getElementById('continent'); cntrySel = document.getElementById('country'); countryList = country[contSel.value]; changeSelect(cntrySel, countryList); setStates(); } function setStates(){ contSel = document.getElementById('continent'); cntrySel = document.getElementById('country'); stateSel = document.getElementById('state'); stateList = states[contSel.value][cntrySel.value]; changeSelect(stateSel, stateList); setCities(); } function setCities(){ contSel = document.getElementById('continent'); cntrySel = document.getElementById('country'); stateSel = document.getElementById('state'); citySel = document.getElementById('city'); cityList = cities[contSel.value][cntrySel.value][stateSel.value]; changeSelect(citySel, cityList); } function changeSelect(fieldObj, valuesAry, optTextAry, selectedValue) { //Clear the select list fieldObj.options.length = 0; //Set the option text to the values if not passed optTextAry = (optTextAry)?optTextAry:valuesAry; //Itterate through the list and create the options for (var i=0; i<valuesAry.length; i++) { selectFlag = (selectedValue && selectedValue==valuesAry[i])?true:false; fieldObj.options[fieldObj.length] = new Option(optTextAry[i], valuesAry[i], false, selectFlag); } } </script> </head> <body onload="setCountry();"> <form name="test" method="POST" action="processingpage.php"> Continent: <select name="continent" id="continent" onchange="setCountry();"> <option value="NorthAmerica">North America</option> <option value="Europe">Europe</option> <option value="Asia">Asia</option> </select> <br> Country: <select name="country" id="country" onchange="setStates();"> <option value="">Please select a country</option> </select> <br> State: <select name="state" id="state" onchange="setCities();"> <option value="">Please select a State/Province</option> </select> <br> City: <select name="city" id="city"> <option value="">Please select a City</option> </select> </form> that doesn't seem to transfer any values However, if you will have NO DUPLICATE VALUES (i.e. the ssame state name in two different countries) this is a more streamlined versions: <script type="text/javascript"> // country lists var country = new Array(); country['NorthAmerica'] = ['Canada','United States']; country['Europe'] = ['Swiss']; country['Asia'] = ['China']; // State lists var states = new Array(); //North America states['Canada'] = ['Alberta','British Columbia','Ontario']; states['United States'] = ['Florida','Oregon']; //Europe states['Swiss'] = ['Test']; //Asia states['China'] = ['ChineseProvince1']; // City lists var cities = new Array(); //North America //--Canada cities['Alberta'] = ['Edmonton','Calgary']; cities['British Columbia'] = ['Victoria','Vancouver']; cities['Ontario'] = ['Toronto','Hamilton']; //--United States cities['Florida'] = ['Orlando']; cities['Oregon'] = ['Portland','Eugene']; //Europe //--Swiss cities['Test'] = ['Zurich']; //Asia //--China cities['ChineseProvince1'] = ['Los Angeles','San Francisco']; function setCountry() { contSel = document.getElementById('continent'); cntrySel = document.getElementById('country'); countryList = country[contSel.value]; changeSelect(cntrySel, countryList); setStates(); } function setStates() { cntrySel = document.getElementById('country'); stateSel = document.getElementById('state'); stateList = states[cntrySel.value]; changeSelect(stateSel, stateList); setCities(); } function setCities() { stateSel = document.getElementById('state'); citySel = document.getElementById('city'); cityList = cities[stateSel.value]; changeSelect(citySel, cityList); } function changeSelect(fieldObj, valuesAry, optTextAry, selectedValue) { //Clear the select list fieldObj.options.length = 0; //Set the option text to the values if not passed optTextAry = (optTextAry)?optTextAry:valuesAry; //Itterate through the list and create the options for (var i=0; i<valuesAry.length; i++) { selectFlag = (selectedValue && selectedValue==valuesAry[i])?true:false; fieldObj.options[fieldObj.length] = new Option(optTextAry[i], valuesAry[i], false, selectFlag); } } </script> </head> <body onload="setCountry();"> <form name="test" method="POST" action="processingpage.php"> Continent: <select name="continent" id="continent" onchange="setCountry();"> <option value="NorthAmerica">North America</option> <option value="Europe">Europe</option> <option value="Asia">Asia</option> </select> <br> Country: <select name="country" id="country" onchange="setStates();"> <option value="">Please select a country</option> </select> <br> State: <select name="state" id="state" onchange="setCities();"> <option value="">Please select a State/Province</option> </select> <br> City: <select name="city" id="city"> <option value="">Please select a City</option> </select> </form> that doesn't seem to transfer any values
-
Where "string" is the string variable: string.replace(/clubs$/i, 'club'); That will change "clubs" or "Clubs" (or any case variations, i.e. it is case insensitive) to "club" if those matches occur at the very end of the string. If you maintain the case of the word, someone else might have a simple replace() solution. I could do it, but would take a few more lines of code using a match() and then rebuilding the string. If you need to maintiain case, please state so.
-
Please be specific. Are you wanting to remove the letter "s" in any string where the word "clubs" exists? Are you wanting to remove the last letter from a string? Are you wanting to remove the letter "s" from any string? Give some details as to what you are trying to accomplish - exactly. substr() would be one possible solution based upon certain parameters. In others it may be inefficient or not even appropriate to use.