0

In my array, I have very long variables that are used as a security token to prevent people who don't have authority to the PHP server out. However, I want to be able to log the data to review for bad actions if the variables passed the security wall, but I can't seem to find a way to exclude some variables to prevent getting my log file too big and rotating frequently.

logissue("User ".$authname." is now preforming ".json_encode($data));

returns and logs this huge hunk of data..

66.***.***.**  2015/08/03 06:28:52  User Nickoplier is now preforming {"Validate":"n@xrbycrzF6*au8c8.....","Action":"message","auth":":ZzWh[a....","Parameter1":"2933***","Parameter2":"hello :D","Parameter3":"just a test"}

Is it possible to exclude logging 'Validate' and 'auth'?

1 Answer 1

3

Yes, simply add:

unset($data['Validate'], $data['auth']);

Before the line converting the array into JSON. You can replicate this with as many array keys as you'd like. You can even exclude sub-keys of child arrays: unset($data['stuff']['more-stuff']['field'])

This will delete that key, so a better way would be to wrap the whole component inside a function and pass $data in.

Sign up to request clarification or add additional context in comments.

1 Comment

Note: unset deletes that entry so be sure that you don't need them later

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.