How to check for availability and then print the value of php?

Please tell me you can do so below in the code
$postResult = preg_replace('/\<\/body\>/i', ".$config[code].".$config[codev].".$config[uptolike_code].'
', $postResult);

$config[uptolike_code] displayed only if $config[uptolike] equal to 1?

Tried to paste in the code above:
if($_POST["uptolike"] == '1') { print ('.$config[uptolike_code].');

nothing happened.

Thank you!
June 14th 19 at 20:08
1 answer
June 14th 19 at 20:10
Solution
if(isset($_POST["uptolike"]) && $_POST["uptolike"] == '1') { print ('.$config[uptolike_code].');
An Sem, please help to paste your code in mine, I put in, I error out. Not there or not inserted. Thank you.
$postResult = preg_replace('/\<\/body\>/i', ".$config[code].".$config[codev].'
 ', $postResult);
- holden.Carro commented on June 14th 19 at 20:13
show all the code of this piece is not clear what you're trying to achieve - moses_Zboncak commented on June 14th 19 at 20:16
it is possible for example so

if (isset($_POST["uptolike"]) && $_POST["uptolike"] == '1'){
 $postResult = preg_replace('/\<\/body\>/i', ".$config[code].".$config[codev].".$config[uptolike_code].", $postResult);
}else{
 $postResult = preg_replace('/\<\/body\>/i', ".$config[code].".$config[codev].", $postResult); 
}


In General, if you want:

$config[uptolike_code] displayed only if $config[uptolike] equal to 1?

So

if (isset($config[uptolike]) && $config[uptolike] == '1')...


But in General, most likely $config[uptolike] should be $config['uptolike'] not?

if (isset($config['uptolike']) && $config['uptolike'] == '1')


In General show code, and do not understand anything, ask one, in the example $_POST["uptolike"] where did that came from... - moses_Zboncak commented on June 14th 19 at 20:19
I cURL the answer, find , and put before him my code from the database
$postResult = preg_replace('/\<\/body\>/i', ".$config[code].".$config[codev].".$config[uptolike_code].'
 ', $postResult);

here I want to code uptolike is output only if the admin is allowed i.e. a value of 1. - holden.Carro commented on June 14th 19 at 20:22
Thank you! It worked, only I $_POST["uptolike"]) && $_POST["uptolike"] replaced by $config["uptolike"]) && $config["uptolike"] as data is retrieved from the database, I have everything working as intended, did the right thing?
Thank you! - holden.Carro commented on June 14th 19 at 20:25
,

$config[code].".$config[codev] there is also likely something wrong, the quotes are not enough, use IDE - moses_Zboncak commented on June 14th 19 at 20:28
Here is the final code for this replacement

if (isset($config["uptolike"]) && $config["uptolike"] == '1'){
 $postResult = preg_replace('/\<\/body\>/i', ".$config[code].".$config[codev].".$config[uptolike_code].", $postResult);
}else{
 $postResult = preg_replace('/\<\/body\>/i', ".$config[code].".$config[codev].", $postResult); 
}

like all the quotes on the spot. - holden.Carro commented on June 14th 19 at 20:31
, can you?

if (isset($config["uptolike"]) && $config["uptolike"] == '1'){
 $postResult = preg_replace('/\<\/body\>/i', $config['code'].$config['codev'].$config['uptolike_code'].", $postResult);
}else{
 $postResult = preg_replace('/\<\/body\>/i', $config['code'].$config['codev'].", $postResult); 
}
- moses_Zboncak commented on June 14th 19 at 20:34
So right?
Just at first I did, my mistake was, made without the 'and it worked, now' works, strange... - holden.Carro commented on June 14th 19 at 20:37

Find more questions by tags PHP