hi everyone im trying to make my program convert all the text in a text area into sms speak ie great becomes gr8 my program connects to a database and retrives old text = great and newtext = gr8 and compares them to the text area to see if it matches but because the program seperates the words into an array by the spaces words like "be right back" becomes "b right back" instead of "brb" here is my code so far also i have an index page that has the text area on it and send the text via the variabl "smstext"
<?php
include("dbcnx.php");
$phrase = $_GET['smstext'];
$sql="SELECT * FROM sms_keywords ORDER BY keyword";
$result=mysql_query($sql);
$a=0;
while($row=mysql_fetch_array($result) {
$oldtext[$a]=$row['keyword'];
$newtext[$a]=$row['replaceWord'];
$a++;
}
//Separate the provided text into separate words
$textArray=explode(" ",$phrase);
$b=0;
foreach($textArray as $word) {
$i=0;
foreach($oldtext as $checkMatch) {
if($word==$checkMatch){
$textArray[$b]=$newtext[$i];
}
$i++;
}
$b++;
}
//output the whole array
foreach($textArray as $finalWord) {
echo $finalWord." ";
}