Jump to content

[SOLVED] Convert separate string variables to simple regular expression element


HowdeeDoodee

Recommended Posts

I need to combine the variable values shown below into a regular expression $composite with a separator of |

 

Any help would be appreciated.

 

Here is an example.

 

$A = "shoe";
$B = "box";
$C = "wrapper";
$termcrm = "crm";
$sep = "|";


$composite = 'shoe|box|wrapper|crm'; 

Link to comment
Share on other sites

OK, gingerrobot thank you for the response. When I tried your suggestion, I got this error message:

 

Parse error: syntax error, unexpected T_VARIABLE

 

The code used was:

 

<?php
$A = 'Hello';
$B = 'World';
$C = 'Beautiful';
$D = 'Day!'

$composite = $A .'|' . $B . '|' . $C . '|' . $D;//

echo $composite;
?> 

 

To chigley...

 

Thank you for the suggestion.

 

The values come into a script. I need to convert the values from $variables but not by hand as you show in your example.

 

Thank both of you again.

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.