Apologies, the script was right - but the data was wrong - I had lots of white space at the end of each string, i have used rtrim to solve this: $DB_ref = rtrim($DB_ref," ");
$DB_temp_ref = $DB_ref; J. -----Original Message----- From: James Meers Sent: Fri 06/02/2004 21:32 To: [EMAIL PROTECTED] Cc: Subject: [PHP-DB] substr() problems Hi all, I am trying to use substr() negative start, but I get nothing returned - if i do a positive start then i do get something back, below is my code and a line of what i get returned: $DB_ref = "210020007"; $DB_temp_ref = $DB_ref; $DB_sub_ref = substr($DB_temp_ref , 0, 1); $DB_sub_ref .= substr($DB_temp_ref , 1, 1); $DB_sub_ref .= substr($DB_temp_ref , -1, 1); echo "$DB_sub_ref - $DB_ref"; RESULT: "21 - 210020007" note: 210020007 is an example this is actually within a while statement using mysql_fetch_array from a SQL query - all results are not returning the negative string. Can anyone help? PHP Version 4.3.3 Apache/2.0.47 (Fedora) Many thanks in advance, James.