Jump to content

Help me Completing First Code of my PHP life


natasha_thomas

Recommended Posts

Friends,

 

I have two array, i have exploded both the arrayes with " " Seperator and now i have words as elements in both the arrays.

 

 

What i am trying to do is, I want to check each element of array2 to each element of Array1, when there is a match, the array2 should

increment by 1, so the next element value of array2 can come.

If no match found, that element of arrar2 show be echoed Contatneted with the Whole String of Array1.

 

Example:

 

Array1 = Paintball mask

Array2 = Paintball tipmann mask v1 series

 

Pick first element of Array2 and check it in all the elements of array1. like (Check "Paintball" in "Paintball tipmann mask v1 series" )

 

If found, increment the Array2 Element by 1. Now again check it in all the elements of array1.

 

If NO match Found, then

 

echo array1 (Whole String)." ".array2 (that particular Element of Array2 for which no occurance found in Array1) (Like: "series" has no occurance in "Paintball mask")

So Echo:

 

Paintball Mask Series

 

And so on....

 

 

 

I have tried to code around it as much as i could do, Need your help to Complete it... PLEASE

 

 

 

 

 



<?php

$keyword = 'Paintball Mask';
$title = 'Paintball tipmann mask v1 series';

$arr_keyword = explode(" ", $keyword);
$arr_title = explode(" ", $title);

foreach ($arr_title as $value)

{
foreach ($arr_keyword  as $innervalue)

{

if ($value != $innervalue)

{

echo $keyword." ".$value; 

}

}



}




}


?>

 

 

I believe to get some help here....

 

Thanks all PHP Geeks...

Natty

Link to comment
Share on other sites

i have one small doubt

in ur example u have

Array1 = Paintball mask

Array2 = Paintball tipmann mask v1 series

 

if by ur rule if u follow then the result should be some thing like this

 

Paintball Tipmann Mask Series

 

not the

 

Paintball Mask Series

 

am i right..?? :shrug:

Link to comment
Share on other sites

i have one small doubt

in ur example u have

Array1 = Paintball mask

Array2 = Paintball tipmann mask v1 series

 

if by ur rule if u follow then the result should be some thing like this

 

Paintball Tipmann Mask Series

 

not the

 

Paintball Mask Series

 

am i right..?? :shrug:

 

 

You just need to pick each element of Array2 and check its avaliablity in array1, if found then Increment Array2 by 1.

 

If  not found then

echo The whole string of Attray1 concatenated with only the "Not FOund" Element of the Array2.

 

example:

 

Array1 = Paintball mask

Array2 = Paintball tipmann mask v1 series

 

Array2's 4th element is V1 and is not avalievle in Array1 so the

 

echo Array1. " ".array2 (Only Element "V1", as its not present in Array1 Elements)

 

So the output will be:

 

"Paintball Mask V1 "

 

 

Make sense?

Link to comment
Share on other sites

completely confused.!!!! :'(

 

array 2's second element is also not available in the array 1

so output would be some thing like that of array 2..

 

 

 

 

Array1 = Paintball mask

Array2 = Paintball tipmann mask v1 series

 

 

Array2's second element is "tipmann"

 

Its not avaliable in Array1, so the output will be...

 

Whole string of Array1 concatenated with That "Not found in Array1 " Element of Array2 i.e. "Tipmann"

 

Final Output:

Paintball Mask Tipmann

 

 

Link to comment
Share on other sites

i have tried some thing like this

check whether this one works

 

<?php

$keyword = 'Paintball Mask';
$title = 'Paintball tipmann Mask v1 series';

$arr_keyword = explode(" ", $keyword);
//print_r($arr_keyword);
echo "<br>";
$arr_title = explode(" ", $title);
//print_r($arr_title);

echo "<br>";
foreach($arr_keyword as $key)
{
    foreach($arr_title as $yek)
    {
        if($key!=$yek)
        {
            $test[]=$yek."<br>";
        }
    }
}
//print_r($test);
echo "<br>";

//$arr_test=explode(" ", $test);
foreach($test as $est)
{
echo $est;
    if(array_key_exists($est,$arr_keyword))
    {
        echo "string exists";
    }
    else
    {
        echo $keyword." ".$est."<br>";
    }
}
?>

Link to comment
Share on other sites

i have exploded both the arrayes with " " Seperator and now i have words

 

You can use str_word_count for that you know.

 

print_r(str_word_count($text, 1));

 

For the script try:

 

$text1 = 'Paintball mask';
$text2 = 'Paintball tipmann mask v1 series';

echo ucfirst($text1), ' ', implode(' ', array_map('ucfirst',
    array_diff(str_word_count(strtolower($text2), 1),
        str_word_count(strtolower($text1), 1))));
//Paintball Mask Tipmann V1 Series

 

Why are you all making it so difficult? If you don't need the First letter uppercase then remove the "array_map('ucfirst'" part.

Link to comment
Share on other sites

i have tried some thing like this

check whether this one works

 

<?php

$keyword = 'Paintball Mask';
$title = 'Paintball tipmann Mask v1 series';

$arr_keyword = explode(" ", $keyword);
//print_r($arr_keyword);
echo "<br>";
$arr_title = explode(" ", $title);
//print_r($arr_title);

echo "<br>";
foreach($arr_keyword as $key)
{
    foreach($arr_title as $yek)
    {
        if($key!=$yek)
        {
            $test[]=$yek."<br>";
        }
    }
}
//print_r($test);
echo "<br>";

//$arr_test=explode(" ", $test);
foreach($test as $est)
{
echo $est;
    if(array_key_exists($est,$arr_keyword))
    {
        echo "string exists";
    }
    else
    {
        echo $keyword." ".$est."<br>";
    }
}
?>

 

Hello,

 

I just tested this code....

 

Output is:

 

tipmann
Paintball Mask tipmann

Mask
Paintball Mask Mask

v1
Paintball Mask v1

series
Paintball Mask series

Paintball
Paintball Mask Paintball

tipmann
Paintball Mask tipmann

v1
Paintball Mask v1

series
Paintball Mask series

 

Observe, We do not want to Concatenate when there is match of Array2 element in array1.

 

So, Output shoud be like:


tipmann
Paintball Mask tipmann

v1
Paintball Mask v1

series
Paintball Mask series

 

What changes we need in the code to get Output like this?

Link to comment
Share on other sites

i have exploded both the arrayes with " " Seperator and now i have words

 

You can use str_word_count for that you know.

 

print_r(str_word_count($text, 1));

 

For the script try:

 

$text1 = 'Paintball mask';
$text2 = 'Paintball tipmann mask v1 series';

echo ucfirst($text1), ' ', implode(' ', array_map('ucfirst',
    array_diff(str_word_count(strtolower($text2), 1),
        str_word_count(strtolower($text1), 1))));
//Paintball Mask Tipmann V1 Series

 

Why are you all making it so difficult? If you don't need the First letter uppercase then remove the "array_map('ucfirst'" part.

 

 

What a Beautiful Code, what a Short Logic, its so Sweet and Poetry.....

 

Ignace, Wondeful Geek ur...

 

Few things i observed:

 

1- The output of the code is ignoring the Numerical postion of an Element. So V1 is coming up like Only "V", I want the numerics to come as is.

 

2- CUrrently the ourput of this code is:

 

Paintball mask Tipmann V Series

 

Seems like all are echoed in one line... Is it possible to Output it like:

 

Paintball mask Tipmann
Paintball mask V1
Paintball mask Series

 

May we achieve both above things ignace?

 

 

Link to comment
Share on other sites

<?php

$keyword = 'Paintball Mask';
$title = 'Paintball tipmann Mask v1 series';

$arr_keyword = explode(" ", $keyword);
//print_r($arr_keyword);
echo "<br>";
$arr_title = explode(" ", $title);
//print_r($arr_title);


foreach($arr_title as $val)
{
    if(!in_array($val,$arr_keyword))
    {
        echo $keyword." ".$val."<br>";
    }
    
}
?>

Link to comment
Share on other sites

<?php

$keyword = 'Paintball Mask';
$title = 'Paintball tipmann Mask v1 series';

$arr_keyword = explode(" ", $keyword);
//print_r($arr_keyword);
echo "<br>";
$arr_title = explode(" ", $title);
//print_r($arr_title);


foreach($arr_title as $val)
{
    if(!in_array($val,$arr_keyword))
    {
        echo $keyword." ".$val."<br>";
    }
    
}
?>

 

 

Sweet & Sugar Chaitu....

 

I have updated this code by adding Uppercase Function and even have changed the Title.. Have a Look:

 

 

$keyword = 'paintball tactical stock tippmann';

$title = 'TIPPMANN Sniper 16" Barrel (For 98 Custom and Custom Pro Markers)';

 

$keyword = ucwords($keyword);

$title = ucwords($title);

 

 

$arr_keyword = explode(" ", $keyword);

//print_r($arr_keyword);

echo "<br>";

$arr_title = explode(" ", $title);

//print_r($arr_title);

 

 

foreach($arr_title as $val)

{

    if(!in_array($val,$arr_keyword))

    {

        echo $keyword." ".$val."<br>";

    }

   

}

 

 

 

Output is:

 

Paintball Tactical Stock Tippmann TIPPMANN

Paintball Tactical Stock Tippmann Sniper

Paintball Tactical Stock Tippmann 16"

Paintball Tactical Stock Tippmann Barrel

Paintball Tactical Stock Tippmann (For

Paintball Tactical Stock Tippmann 98

Paintball Tactical Stock Tippmann Custom

Paintball Tactical Stock Tippmann And

Paintball Tactical Stock Tippmann Custom

Paintball Tactical Stock Tippmann Pro

Paintball Tactical Stock Tippmann Markers)

 

 

Observations:

 

1 - The first output has duplicate element "TIPPMANN", Even if the Case is Upper it still is a Duplicate, how to handle this bit? This output should not even appear in Output.

 

2- Observe this Output "Paintball Tactical Stock Tippmann (For"  See the Open Bracker before "For", Any way to Remove such Special Character before and after Array Element?

 

3- Most Important Thing: I just did a Live Test of this Code and Found, In Array2 there can be Many Keywords like (For, In, the, a , you, we, all, are, up, down and so on).... I sureply want to Ignore these Set fo Keywords to be used in Output at all.

 

For Example: Where Array2 Element has Words as "all", the Code should jsut ignore the Word and Increment the Array2 by Next Element and do the same Process, this way, we can Keep Away from Such Junk Keywords.....

 

How can this be Handled????

 

Thank you Chaitu....  So Much..

 

Nat.

 

 

 

 

Link to comment
Share on other sites

1- The output of the code is ignoring the Numerical postion of an Element. So V1 is coming up like Only "V", I want the numerics to come as is.

 

Fall back to explode(' ', str_word_count really looks for words and filters everything else.

 

echo ucfirst($text1), ' ', implode(' ', array_map('ucfirst',
    array_diff(explode(' ', strtolower($text2)),
        explode(' ', strtolower($text1))))));

 

As for your second question, try:

 

$map = array_map('ucfirst', array_diff(explode(' ', strtolower($text2)), explode(' ', strtolower($text1))));

foreach ($map as $element) {
  echo $text1, ' ', $element;
}

 

3- Most Important Thing: I just did a Live Test of this Code and Found, In Array2 there can be Many Keywords like (For, In, the, a , you, we, all, are, up, down and so on).... I sureply want to Ignore these Set fo Keywords to be used in Output at all.

 

This is starting to feel like a challenge :)

 

function explode_conditional($delimiter, $string, $conditional = array()) {
  return array_diff(explode($delimiter, $string), $conditional);
}

print_r(explode_conditional(' ', $text2, array('and', 'or', ..)));

Link to comment
Share on other sites

1- The output of the code is ignoring the Numerical postion of an Element. So V1 is coming up like Only "V", I want the numerics to come as is.

 

Fall back to explode(' ', str_word_count really looks for words and filters everything else.

 

echo ucfirst($text1), ' ', implode(' ', array_map('ucfirst',
    array_diff(explode(' ', strtolower($text2)),
        explode(' ', strtolower($text1))))));

 

As for your second question, try:

 

$map = array_map('ucfirst', array_diff(explode(' ', strtolower($text2)), explode(' ', strtolower($text1))));

foreach ($map as $element) {
  echo $text1, ' ', $element;
}

 

3- Most Important Thing: I just did a Live Test of this Code and Found, In Array2 there can be Many Keywords like (For, In, the, a , you, we, all, are, up, down and so on).... I sureply want to Ignore these Set fo Keywords to be used in Output at all.

 

This is starting to feel like a challenge :)

 

function explode_conditional($delimiter, $string, $conditional = array()) {
  return array_diff(explode($delimiter, $string), $conditional);
}

print_r(explode_conditional(' ', $text2, array('and', 'or', ..)));

 

Very Sweet Ignace...

 

Observe I changed the Title:

 

$text1 = 'paintball tactical stock tippmann';
$text2 = 'TIPPMANN Sniper 16" Barrel (For 98 Custom and Custom Pro Markers)';

echo ucfirst($text1), ' ', implode(' ', array_map('ucfirst',
    array_diff(explode(' ', strtolower($text2)),
        explode(' ', strtolower($text1)))));

$map = array_map('ucfirst', array_diff(explode(' ', strtolower($text2)), explode(' ', strtolower($text1))));

foreach ($map as $element) {
  echo $text1, ' ', $element.'<br/>';
}

 

 

Output:

 

Paintball tactical stock tippmann Sniper 16" Barrel (for 98 Custom And Custom Pro Markers)
paintball tactical stock tippmann Sniper
paintball tactical stock tippmann 16"
paintball tactical stock tippmann Barrel
paintball tactical stock tippmann (for
paintball tactical stock tippmann 98
paintball tactical stock tippmann Custom
paintball tactical stock tippmann And
paintball tactical stock tippmann Custom
paintball tactical stock tippmann Pro
paintball tactical stock tippmann Markers)

 

 

Observations:

1- Observe this Output "Paintball Tactical Stock Tippmann (For"  See the Open Bracker before "For", Any way to Remove such Special Character before and after Array Element?

 

2-  Observe In the output, "paintball tactical stock tippmann Custom", Is appearing Twice. Not able to figure out, why is it happening?

 

3- Most Important Thing: I just did a Live Test of this Code and Found, In Array2 there can be Many Keywords like (For, In, the, a , you, we, all, are, up, down and so on).... I sureply want to Ignore these Set fo Keywords to be used in Output at all.

 

 

 

For Example: Where Array2 Element has Words as "all", the Code should jsut ignore the Word and Increment the Array2 by Next Element and do the same Process, this way, we can Keep Away from Such Junk Keywords.....

 

How can this be Handled????

 

Thank you Ignace...  8)

 

Nat.

 

 

 

 

Link to comment
Share on other sites

1- Observe this Output "Paintball Tactical Stock Tippmann (For"  See the Open Bracker before "For", Any way to Remove such Special Character before and after Array Element?

 

$text = preg_replace('/[^a-z0-9"\s]/i', '', $text);

 

Removes everything except A-Z 0-9, " and spaces.

 

2-  Observe In the output, "paintball tactical stock tippmann Custom", Is appearing Twice. Not able to figure out, why is it happening?

 

function filter_duplicate($text) {
  $explode = explode(' ', $text);
  return implode(' ', array_diff($explode, $explode));
}

 

3- Most Important Thing: I just did a Live Test of this Code and Found, In Array2 there can be Many Keywords like (For, In, the, a , you, we, all, are, up, down and so on).... I sureply want to Ignore these Set fo Keywords to be used in Output at all.

 

Like I already said use

 

function explode_conditional($delimiter, $string, $conditional = array()) {
  return array_diff(explode($delimiter, $string), $conditional);
}

print_r(explode_conditional(' ', $text2, array('and', 'or', ..)));

 

You will have to provide the list of words you want filtered out yourself.

Link to comment
Share on other sites

1

 

2-  Observe In the output, "paintball tactical stock tippmann Custom", Is appearing Twice. Not able to figure out, why is it happening?

 

function filter_duplicate($text) {
  $explode = explode(' ', $text);
  return implode(' ', array_diff($explode, $explode));
}

 

My Change in Code:

 

$text1 = 'paintball tactical stock tippmann';
$text2 = 'TIPPMANN Sniper 16" Barrel (For 98 Custom and Custom Pro Markers)';

echo ucfirst($text1), ' ', implode(' ', array_map('ucfirst',
    array_diff(explode(' ', strtolower($text2)),
        explode(' ', strtolower($text1)))));

$map = array_map('ucfirst', array_diff(explode(' ', strtolower($text2)), explode(' ', strtolower($text1))));

// I added Duplicate Filtering Function Here
function filter_duplicate($text) {
  $explode = explode(' ', $text);
  return implode(' ', array_diff($explode, $explode));
}



foreach ($map as $element) {
//I am Calling Duplicate Filter function below 
echo filter_duplicate($text1), ' ', $element.'<br/>';
}

 

OutPut:

 

Paintball tactical stock tippmann Sniper 16" Barrel (for 98 Custom And Custom Pro Markers) Sniper
16"
Barrel
(for
98
Custom
And
Custom
Pro
Markers)

 

Seems I messup somewhere, not able to trackback Where...  :'(

 

 

 

 

2:

 

3- Most Important Thing: I just did a Live Test of this Code and Found, In Array2 there can be Many Keywords like (For, In, the, a , you, we, all, are, up, down and so on).... I sureply want to Ignore these Set fo Keywords to be used in Output at all.

 

function explode_conditional($delimiter, $string, $conditional = array()) {
  return array_diff(explode($delimiter, $string), $conditional);
}

print_r(explode_conditional(' ', $text2, array('and', 'or', ..)));

 

 

My Code Changes:

 

Am not able to Figure out, where do i have too integreate this Code Bit?

 

BTW, The KW list that i want to Exclude are:

 

a, we, are, in, all, you, u, for, up, down

 

 

 

 

3:

In the Output If you observe, the First line is:

Paintball tactical stock tippmann Sniper 16" Barrel (for 98 Custom And Custom Pro Markers)

 

Which is nothign but the concatenation of all the Unique strings, any way to remove this from Output, as i do not want it, in output, i tried to Remove the Echo and it gave me error.

 

Output Should be:

 

paintball tactical stock tippmann Sniper

paintball tactical stock tippmann 16"

paintball tactical stock tippmann Barrel

paintball tactical stock tippmann (for

paintball tactical stock tippmann 98

paintball tactical stock tippmann Custom

paintball tactical stock tippmann And

paintball tactical stock tippmann Custom

paintball tactical stock tippmann Pro

 

 

What in the existing code to be removed to achieve this?

 

Thanks a lot Igace for being here.... Apolozied for taking your time...

 

Natty T.

 

 

Link to comment
Share on other sites

1, 2:

 

function filter_duplicate($array) {
  return array_diff($array, $array);
}

function explode_conditional($delimiter, $string, $conditional = array()) {
  return array_diff(explode($delimiter, $string), $conditional);
}

$bad = array('a', 'we', 'are', 'in', 'all', 'you', 'u', 'for', 'up', 'down');

$text1 = 'paintball tactical stock tippmann';
$text2 = 'TIPPMANN Sniper 16" Barrel (For 98 Custom and Custom Pro Markers)'

$array1 = explode(' ', strtolower($text1));
$array2 = filter_duplicate(explode_conditional(' ', preg_replace('/[^a-z0-9"\s]/i', '', strtolower($text2)), $bad));

$map = array_map('ucfirst', array_diff($array2, $array1));

foreach ($map as $element) {
  echo $text1, ' ', $element, "<br/>\n";
}

 

3:

 

Is this the output you want?

 

paintball tactical stock tippmann Sniper

paintball tactical stock tippmann 16"

paintball tactical stock tippmann Barrel

paintball tactical stock tippmann (for

paintball tactical stock tippmann 98

paintball tactical stock tippmann Custom

paintball tactical stock tippmann And

paintball tactical stock tippmann Custom

paintball tactical stock tippmann Pro

Link to comment
Share on other sites

1,2:

 

function filter_duplicate($array) {
  return array_diff($array, $array);
}

function explode_conditional($delimiter, $string, $conditional = array()) {
  return array_diff(explode($delimiter, $string), $conditional);
}

$bad = array('a', 'we', 'are', 'in', 'all', 'you', 'u', 'for', 'up', 'down');

$text1 = 'paintball tactical stock tippmann';
$text2 = 'TIPPMANN Sniper 16" Barrel (For 98 Custom and Custom Pro Markers)'

$array1 = explode(' ', strtolower($text1));
$array2 = filter_duplicate(explode_conditional(' ', preg_replace('/[^a-z0-9"\s]/i', '', strtolower($text2)), $bad));

$map = array_map('ucfirst', array_diff($array2, $array1));

foreach ($map as $element) {
  echo $text1, ' ', $element, "<br/>\n";
}

 

This Code is Outputting An Error:

 

Parse error: syntax error, unexpected T_VARIABLE in /homepages

 

What this error about...

 

Note:I am using Online Tool to Execute PHP

 

 

 

 

 

3:

 

paintball tactical stock tippmann Sniper

paintball tactical stock tippmann 16"

paintball tactical stock tippmann Barrel

paintball tactical stock tippmann (for

paintball tactical stock tippmann 98

paintball tactical stock tippmann Custom

paintball tactical stock tippmann And

paintball tactical stock tippmann Custom

paintball tactical stock tippmann Pro

 

 

Exactly What i am looking for...  :D  (Post Adding thoese above 1,2 Codes)

 

Thanks for all Ignace...  8)

 

Natty T.

 

Link to comment
Share on other sites

I have checked this code on http://writecodeonline.com/php/

 

function filter_duplicate($array) {
  return array_unique($array);
}

function explode_conditional($delimiter, $string, $conditional = array()) {
  return array_diff(explode($delimiter, $string), $conditional);
}

$bad = array('a', 'we', 'are', 'in', 'all', 'you', 'u', 'for', 'up', 'down');

$text1 = 'paintball tactical stock tippmann';
$text2 = 'TIPPMANN Sniper 16" Barrel (For 98 Custom and Custom Pro Markers)';

$array1 = explode(' ', strtolower($text1));
$array2 = filter_duplicate(explode_conditional(' ', preg_replace('/[^a-z0-9"\s]/i', '', strtolower($text2)), $bad));

$map = array_map('ucfirst', array_diff($array2, $array1));

$text1 = ucwords($text1);
foreach ($map as $element) {
  echo $text1, ' ', $element, "<br/>\n";
}

 

Returns

 

Paintball Tactical Stock Tippmann Sniper

Paintball Tactical Stock Tippmann 16"

Paintball Tactical Stock Tippmann Barrel

Paintball Tactical Stock Tippmann 98

Paintball Tactical Stock Tippmann Custom

Paintball Tactical Stock Tippmann And

Paintball Tactical Stock Tippmann Pro

Paintball Tactical Stock Tippmann Markers

Link to comment
Share on other sites

I have checked this code on http://writecodeonline.com/php/

 

function filter_duplicate($array) {
  return array_unique($array);
}

function explode_conditional($delimiter, $string, $conditional = array()) {
  return array_diff(explode($delimiter, $string), $conditional);
}

$bad = array('a', 'we', 'are', 'in', 'all', 'you', 'u', 'for', 'up', 'down');

$text1 = 'paintball tactical stock tippmann';
$text2 = 'TIPPMANN Sniper 16" Barrel (For 98 Custom and Custom Pro Markers)';

$array1 = explode(' ', strtolower($text1));
$array2 = filter_duplicate(explode_conditional(' ', preg_replace('/[^a-z0-9"\s]/i', '', strtolower($text2)), $bad));

$map = array_map('ucfirst', array_diff($array2, $array1));

$text1 = ucwords($text1);
foreach ($map as $element) {
  echo $text1, ' ', $element, "<br/>\n";
}

 

Returns

 

Paintball Tactical Stock Tippmann Sniper

Paintball Tactical Stock Tippmann 16"

Paintball Tactical Stock Tippmann Barrel

Paintball Tactical Stock Tippmann 98

Paintball Tactical Stock Tippmann Custom

Paintball Tactical Stock Tippmann And

Paintball Tactical Stock Tippmann Pro

Paintball Tactical Stock Tippmann Markers

 

 

Dear Ignace,

 

I just have run through this code in Writecodeonline.com and got the below Output:

 

Paintball Tactical Stock Tippmann Tippmannsniper16"barrelfor98customandcustompromarkers

n

 

Is it not what you got as Output?

 

Thank for all Ignace!!!

N

 

Link to comment
Share on other sites

Paintball Tactical Stock Tippmann Tippmannsniper16"barrelfor98customandcustompromarkers

 

Yeah I should have mentioned this, I noticed that the online service strips backward slashes (\) To avoid this you need to add another backward slash, like so (find \\s and \\n):

 

function filter_duplicate($array) {
  return array_unique($array);
}

function explode_conditional($delimiter, $string, $conditional = array()) {
  return array_diff(explode($delimiter, $string), $conditional);
}

$bad = array('a', 'we', 'are', 'in', 'all', 'you', 'u', 'for', 'up', 'down');

$text1 = 'paintball tactical stock tippmann';
$text2 = 'TIPPMANN Sniper 16" Barrel (For 98 Custom and Custom Pro Markers)';

$array1 = explode(' ', strtolower($text1));
$array2 = filter_duplicate(explode_conditional(' ', preg_replace('/[^a-z0-9"\\s]/i', '', strtolower($text2)), $bad));

$map = array_map('ucfirst', array_diff($array2, $array1));

$text1 = ucwords($text1);
foreach ($map as $element) {
  echo $text1, ' ', $element, "<br/>\\n";
}

 

Execute this code twice, once to see the output I got before and the second time to see your result so you know the script actually works. To use this script on your server you need not this one but the previous one.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.